我正在浏览Django教程:https://docs.djangoproject.com/en/1.5/intro/tutorial01/
我有一个错误:
TypeError:
__init__()
有一个意外的关键字参数'Default'
当我打电话时会发生这种情况:
$python manage.py sql polls
OR
$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 models
class 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 polls - >发生错误
答案 0 :(得分:3)
在您的模型定义中,您有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