I am following the official Django documentation and trying to make the polls app. But when I run the command python manage.py makemigrations polls I get the console error.
我正在跟踪Django的官方文档并尝试使用polling应用程序。但是当我运行命令python管理时。py移民投票我得到控制台错误。
anupam@Anupam-HP:~/Python/django/mysite$ python manage.py makemigrations polls
Traceback (most recent call last):
File "manage.py", line 10, in <module>
execute_from_command_line(sys.argv)
File "/usr/local/lib/python2.7/dist-packages/Django-1.7.2-py2.7.egg/django/ core/management/__init__.py", line 385, in execute_from_command_line
utility.execute()
File "/usr/local/lib/python2.7/dist-packages/Django-1.7.2-py2.7.egg/django/core/management/__init__.py", line 354, in execute
django.setup()
File "/usr/local/lib/python2.7/dist-packages/Django-1.7.2-py2.7.egg/django/__init__.py", line 21, in setup
apps.populate(settings.INSTALLED_APPS)
File "/usr/local/lib/python2.7/dist-packages/Django-1.7.2-py2.7.egg/django/apps/registry.py", line 108, in populate
app_config.import_models(all_models)
File "/usr/local/lib/python2.7/dist-packages/Django-1.7.2-py2.7.egg/django/apps/config.py", line 202, in import_models
self.models_module = import_module(models_module_name)
File "/usr/lib/python2.7/importlib/__init__.py", line 37, in import_module
__import__(name)
File "/home/anupam/Python/django/mysite/polls/models.py", line 13
^
SyntaxError: invalid syntax
The code I am using for the models is:
我为这些模型使用的代码是:
from django.db import models
class Question(models.Model):
question_text = models.CharField(max_length=200)
pub_date = models.DateTimeField('date published')
class Choice(models.Model):
question = models.ForeignKey(Question)
choice_text = models.CharField(max_length=200)
votes = models.IntegerField(default=
It would be great if you could point out the error.
如果你能指出错误,那就太好了。
1 个解决方案
#1
2
The error line is the last line of your models.py
:
错误线是您的模型的最后一行。
votes = models.IntegerField(default=
It should be:
应该是:
votes = models.IntegerField(default=0)
#1
2
The error line is the last line of your models.py
:
错误线是您的模型的最后一行。
votes = models.IntegerField(default=
It should be:
应该是:
votes = models.IntegerField(default=0)