在python中使用Makemigrations时出错

时间:2017-08-07 15:02:47

标签: python django python-3.x

我对django来说是全新的,所以任何帮助都会受到赞赏 我编写了以下代码,在我的终端中,我使用了python manage.py makemigrations并出现了错误

django模型

class ctrybe(models.Model):
    name = models.CharField(max_lenght=120)

    def __unicode__(self):
        return self.name

终端错误

Traceback (most recent call last):
  File "manage.py", line 22, in <module>
    execute_from_command_line(sys.argv)
  File "/Users/Olar/Desktop/tryTen/lib/python2.7/site-packages/django/core/management/__init__.py", line 363, in execute_from_command_line
    utility.execute()
  File "/Users/Olar/Desktop/tryTen/lib/python2.7/site-packages/django/core/management/__init__.py", line 337, in execute
    django.setup()
  File "/Users/Olar/Desktop/tryTen/lib/python2.7/site-packages/django/__init__.py", line 27, in setup
    apps.populate(settings.INSTALLED_APPS)
  File "/Users/Olar/Desktop/tryTen/lib/python2.7/site-packages/django/apps/registry.py", line 108, in populate
    app_config.import_models()
  File "/Users/Olar/Desktop/tryTen/lib/python2.7/site-packages/django/apps/config.py", line 202, in import_models
    self.models_module = import_module(models_module_name)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/importlib/__init__.py", line 37, in import_module
    __import__(name)
  File "/Users/Olar/Desktop/tryTen/src/ctrybe/models.py", line 7, in <module>
    class ctrybe(models.Model):
  File "/Users/Olar/Desktop/tryTen/src/ctrybe/models.py", line 8, in ctrybe
    name = models.CharField(max_lenght=120)
  File "/Users/Olar/Desktop/tryTen/lib/python2.7/site-packages/django/db/models/fields/__init__.py", line 1061, in __init__
    super(CharField, self).__init__(*args, **kwargs)
TypeError: __init__() got an unexpected keyword argument 'max_lenght'

我使用python 3.4

1 个答案:

答案 0 :(得分:1)

这是一个简单的拼写错误。它应该是max_length,而不是max_lenght