2010年05月25日 星期二 10:24
这段代码从DJANGO 哪里copy的 但是我mysql连接正常啊。。。
结果添加这段代码就报了错误。。
from django.db import models
class Publisher(models.Model):
name = models.CharField(maxlength=30)
address = models.CharField(maxlength=50)
city = models.CharField(maxlength=60)
state_province = models.CharField(maxlength=30)
country = models.CharField(maxlength=50)
website = models.URLField()
class Author(models.Model):
salutation = models.CharField(maxlength=10)
first_name = models.CharField(maxlength=30)
last_name = models.CharField(maxlength=40)
email = models.EmailField()
headshot = models.ImageField(upload_to='/tmp')
class Book(models.Model):
title = models.CharField(maxlength=100)
authors = models.ManyToManyField(Author)
publisher = models.ForeignKey(Publisher)
publication_date = models.DateField()
File "/usr/lib/python2.6/site-packages/django/core/management/commands/runserver.py", line 48, in inner_run
self.validate(display_num_errors=True)
File "/usr/lib/python2.6/site-packages/django/core/management/base.py", line 245, in validate
num_errors = get_validation_errors(s, app)
File "/usr/lib/python2.6/site-packages/django/core/management/validation.py", line 28, in get_validation_errors
for (app_name, error) in get_app_errors().items():
File "/usr/lib/python2.6/site-packages/django/db/models/loading.py", line 146, in get_app_errors
self._populate()
File "/usr/lib/python2.6/site-packages/django/db/models/loading.py", line 61, in _populate
self.load_app(app_name, True)
File "/usr/lib/python2.6/site-packages/django/db/models/loading.py", line 78, in load_app
models = import_module('.models', app_name)
File "/usr/lib/python2.6/site-packages/django/utils/importlib.py", line 35, in import_module
__import__(name)
File "/home/B.Qnyd/working/mysite/../mysite/books/models.py", line 5, in <module>
class Publishers(models.Model):
File "/home/B.Qnyd/working/mysite/../mysite/books/models.py", line 6, in Publishers
name = models.CharField(maxlength=30)
File "/usr/lib/python2.6/site-packages/django/db/models/fields/__init__.py", line 542, in __init__
super(CharField, self).__init__(*args, **kwargs)
TypeError: __init__() got an unexpected keyword argument 'maxlength'
2010年05月25日 星期二 10:46
是max_length而不是maxlength
2010年05月25日 星期二 10:50
maxlength or max_length ?
2010年05月25日 星期二 10:50
晕,楼上比我快。。
2010年05月25日 星期二 10:52
django 0.96之后对编码风格进行了修改,你用的是1.0之前的例子吧
2010年05月25日 星期二 11:20
对。。
嘿嘿,非常感谢大家~~ 我这个问题在 官方的man找到了。。
Zeuux © 2024
京ICP备05028076号