【发布时间】:2018-02-28 16:17:32
【问题描述】:
模型.py
from django.db import models
class Albums(models.Model):
artist = models.CharField(max_lenght=250)
Albums_Name = models.CharField(max_lenght = 500)
Album_logo = models.CharField(max_lenght = 250)
class Songs(models.Model):
albums=models.ForeignKey(Albums,on_delete=models.CASCADE)
file_type = models.CharField(max_lenght = 500)
Song_title = models.CharField(max_lenght = 500)
setting.py
INSTALLED_APPS = [
'Ganaana.apps.GanaanaConfig',
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles', ]
错误:
命令使用:python manage.py makemigrations Ganaana
回溯(最近一次通话最后):
文件“manage.py”,第 22 行,在
execute_from_command_line(sys.argv)
文件“C:\Program Files\Python36\lib\site-packages\django-1.11.5-
py3.6.egg\django\core\management__init__.py",第 364 行,正在执行中
e_from_command_line
实用程序.execute()
文件“C:\Program Files\Python36\lib\site-packages\django-1.11.5-
py3.6.egg\django\core\management__init__.py",第 338 行,在执行中
django.setup()
文件“C:\Program Files\Python36\lib\site-packages\django-1.11.5-
py3.6.egg\django__init__.py",第 27 行,在设置中
apps.populate(settings.INSTALLED_APPS)
文件“C:\Program Files\Python36\lib\site-packages\django-1.11.5
py3.6.egg\django\apps\registry.py",第 108 行,在填充
app_config.import_models()
文件“C:\Program Files\Python36\lib\site-packages\django-1.11.5-
py3.6.egg\django\apps\config.py",第 202 行,在 import_models
self.models_module = import_module(models_module_name)
文件“C:\Program Files\Python36\lib\importlib__init__.py”,第 126 行,在
导入模块
return _bootstrap._gcd_import(name[level:], package, level)
_gcd_import 中的文件“”,第 978 行
_find_and_load 中的文件“”,第 961 行
文件“”,第 950 行,在 _find_and_load_unlocked
_load_unlocked 中的文件“”,第 655 行
文件“”,第 678 行,在 exec_module 中
_call_with_frames_removed 中的文件“”,第 205 行
文件“E:\PythonDjango\website\Ganaana\models.py”,第 4 行,在
类专辑(models.Model):
相册中的文件“E:\PythonDjango\website\Ganaana\models.py”,第 5 行
艺术家 = models.CharField(self,max_lenght = 250)
NameError:名称“自我”未定义
PS E:\PythonDjango\website> python manage.py makemigration Ganaana
回溯(最近一次通话最后):
文件“manage.py”,第 22 行,在
execute_from_command_line(sys.argv)
文件“C:\Program Files\Python36\lib\site-packages\django-1.11.5-
py3.6.egg\django\core\management__init__.py",第 364 行,正在执行中
e_from_command_line
实用程序.execute()
文件“C:\Program Files\Python36\lib\site-packages\django-1.11.5-
py3.6.egg\django\core\management__init__.py",第 338 行,在执行中
django.setup()
文件“C:\Program Files\Python36\lib\site-packages\django-1.11.5-
py3.6.egg\django__init__.py",第 27 行,在设置中
apps.populate(settings.INSTALLED_APPS)
文件“C:\Program Files\Python36\lib\site-packages\django-1.11.5-
py3.6.egg\django\apps\registry.py",第 108 行,在填充
app_config.import_models()
文件“C:\Program Files\Python36\lib\site-packages\django-1.11.5-
py3.6.egg\django\apps\config.py",第 202 行,在 import_models
self.models_module = import_module(models_module_name)
文件“C:\Program Files\Python36\lib\importlib__init__.py”,第 126 行,在
导入模块
return _bootstrap._gcd_import(name[level:], package, level)
_gcd_import 中的文件“”,第 978 行
_find_and_load 中的文件“”,第 961 行
文件“”,第 950 行,在 _find_and_load_unlocked
PS E:\PythonDjango\website> python manage.py makemigration Ganaana
回溯(最近一次通话最后):
文件“manage.py”,第 22 行,在
execute_from_command_line(sys.argv)
文件“C:\Program Files\Python36\lib\site-packages\django-1.11.5-
py3.6.egg\django\core\management__init__.py",第 364 行,正在执行中
e_from_command_line
实用程序.execute()
文件“C:\Program Files\Python36\lib\site-packages\django-1.11.5-
py3.6.egg\django\core\management__init__.py",第 338 行,在执行中
django.setup()
文件“C:\Program Files\Python36\lib\site-packages\django-1.11.5-
py3.6.egg\django__init__.py",第 27 行,在设置中
apps.populate(settings.INSTALLED_APPS)
文件“C:\Program Files\Python36\lib\site-packages\django-1.11.5-
py3.6.egg\django\apps\registry.py",第 108 行,在填充
app_config.import_models()
文件“C:\Program Files\Python36\lib\site-packages\django-1.11.5-
py3.6.egg\django\apps\config.py",第 202 行,在 import_models
self.models_module = import_module(models_module_name)
文件“C:\Program Files\Python36\lib\importlib__init__.py”,第 126 行,在
导入模块
return _bootstrap._gcd_import(name[level:], package, level)
_gcd_import 中的文件“”,第 978 行
_find_and_load 中的文件“”,第 961 行
文件“”,第 950 行,在 _find_and_load_unlocked
_load_unlocked 中的文件“”,第 655 行
文件“”,第 678 行,在 exec_module 中
_call_with_frames_removed 中的文件“”,第 205 行
文件“E:\PythonDjango\website\Ganaana\models.py”,第 4 行,在
类专辑(models.Model):
相册中的文件“E:\PythonDjango\website\Ganaana\models.py”,第 5 行
艺术家 = models.CharField(max_lenght=250)
文件“C:\Program Files\Python36\lib\site-packages\django-1.11.5-
py3.6.egg\django\db\models\fields__init__.py",第 1061 行,在 init 中
super(CharField, self).init(*args, **kwargs)
TypeError: init() 得到了一个意外的关键字参数“max_lenght”
我不明白我的错误?我给了一个正确的名字仍然出错?任何人都可以识别错误
【问题讨论】:
-
你把 ``max_length``` 拼错为
max_lenght
标签: django