我正在阅读Django教程:https : //docs.djangoproject.com/en/1.5/intro/tutorial01/我有一个错误:TypeError:__init__()出现了意外的关键字参数'Default'当我打电话时会发生这种情况:$python manage.py sql polls 或者$python manage.py syncdb我被困住了,无法弄清楚我在做什么错。我刚刚开始了本教程的“激活模型”部分,并输入了已安装的应用程序引用:[settings.py]'Engine': 'django.db.backends.sqlite3''NAME': '/Users/msmith/Documents/djangoPractice/database.db'$ python manage.py syncdb$ python manage.py startapp polls[polls.models.py]from django.db import modelsclass Poll(models.Model): question = models.CharField(max_length=200) pub_date = models.DateTimeField('date published')class Choice(models.Model): poll = models.ForeignKey(Poll) choice_text = models.CharField(max_length=200) votes = models.IntegerField(Default=0)[settings.py]-在列表底部添加了“民意调查”INSTALLED_APPS = ( 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.sites', 'django.contrib.messages', 'django.contrib.staticfiles', # Uncomment the next line to enable the admin: # 'django.contrib.admin', # Uncomment the next line to enable admin documentation: # 'django.contrib.admindocs', 'polls',)$ python manage.py sql民意调查->发生错误
1 回答
慕少森
TA贡献2019条经验 获得超9个赞
在模型定义中,您有Default=而不是default=。检查情况。
class Choice(models.Model):
poll = models.ForeignKey(Poll)
choice_text = models.CharField(max_length=200)
votes = models.IntegerField(default=0)
# ^ Check the case here
添加回答
举报
0/150
提交
取消