开发者

Why do I get this error when I run manage.py validate?

开发者 https://www.devze.com 2023-01-08 10:22 出处:网络
Why do I get this error when I run manage.py validate?: Traceback (most recent call last): File \"manage.py\", line 11, in <module>

Why do I get this error when I run manage.py validate?:

Traceback (most recent call last):
  File "manage.py", line 11, in <module>
    execute_manager(settings)
  File "C:\python26\lib\site-packages\django\core\management\__init__.py", line
438, in execute_manager
    utility.execute()
  File "C:\python26\lib\site-packages\django\core\management\__init__.py", line
379, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "C:\python26\lib\site-packages\django\core\management\base.py", line 191,
 in run_from_argv
    self.execute(*args, **options.__dict__)
  File "C:\python26\lib\site-packages\django\core\management\base.py", line 218,
 in execute
    output = self.handle(*args, **options)
  File "C:\python26\lib\site-packages\django\core\management\base.py", line 347,
 in handle
    return self.handle_noargs(**options)
  File "C:\python26\lib\site-packages\django\core\management\commands\validate.p
y", line 9, in handle_noargs
    self.validate(display_num_errors=True)
  File "C:\python26\lib\site-packages\django\core\management\base.py", line 245,开发者_如何学运维
 in validate
    num_errors = get_validation_errors(s, app)
  File "C:\python26\lib\site-packages\django\core\management\validation.py", lin
e 28, in get_validation_errors
    for (app_name, error) in get_app_errors().items():
  File "C:\python26\lib\site-packages\django\db\models\loading.py", line 146, in
 get_app_errors
    self._populate()
  File "C:\python26\lib\site-packages\django\db\models\loading.py", line 61, in
_populate
    self.load_app(app_name, True)
  File "C:\python26\lib\site-packages\django\db\models\loading.py", line 78, in
load_app
    models = import_module('.models', app_name)
  File "C:\python26\lib\site-packages\django\utils\importlib.py", line 35, in im
port_module
    __import__(name)
  File "C:\projects\mysite\..\mysite\books\models.py", line 5, in <module>
    class Publisher(models.Model):
  File "C:\projects\mysite\..\mysite\books\models.py", line 6, in Publisher
    name = models.CharField(maxlength=30)
  File "C:\python26\lib\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'


The problem is that you are using a newer version of Django now. Since 1.0 (or actually, somewhere in 0.97) Django switched to max_length instead of maxlength. So either upgrade your code or install Django 0.96 for it to work again.


It's difficult to be 100% sure, because you haven't included the code in mysite/books/models.py, but it would appear that the 'max_length' keyword argument to a CharField in the Publisher class has been misspelled 'maxlength'.

See here for the correct values:

http://docs.djangoproject.com/en/dev/ref/models/fields/#charfield

0

精彩评论

暂无评论...
验证码 换一张
取 消