Django 1.7 python manage.py makemigrations polls SyntaxError

时间:2015-01-10 13:14:16

标签: python django django-models

我正在关注官方的Django文档,并试图制作民意调查应用程序。 但是当我运行命令python manage.py makemigrations民意调查时,我得到了控制台错误。

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

我用于模型的代码是:

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=

如果你能指出错误,那将会很棒。

1 个答案:

答案 0 :(得分:2)

错误行是models.py的最后一行:

votes = models.IntegerField(default=

应该是:

votes = models.IntegerField(default=0)