我正在閱讀Django教程:https : //docs.djangoproject.com/en/1.5/intro/tutorial01/我有一個錯誤:TypeError:__init__()出現(xiàn)了意外的關(guān)鍵字參數(shù)'Default'當(dāng)我打電話時會發(fā)生這種情況:$python manage.py sql polls 或者$python manage.py syncdb我被困住了,無法弄清楚我在做什么錯。我剛剛開始了本教程的“激活模型”部分,并輸入了已安裝的應(yīng)用程序引用:[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]-在列表底部添加了“民意調(diào)查”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民意調(diào)查->發(fā)生錯誤
1 回答

慕少森
TA貢獻(xiàn)2019條經(jīng)驗(yàn) 獲得超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
提交
取消