model_state = state.models[app_label, self.name_lower]
I am trying to run
[code]python manage.py migrate
or
[code]python manage.py makemigrations
I got this error:
C:\Users\ce\dr1>python manage.py makemigrations TestModel
Traceback (most recent call last):
File "manage.py", line 21, in <module>
main()
File "manage.py", line 17, in main
execute_from_command_line(sys.argv)
File "C:\Users\ce\AppData\Local\Programs\Python\Python37\lib\site-packages\django-2.2.4-py3.7.egg\django\core\management\__init__.py",
line 381, in execute_from_command_line
utility.execute()
File "C:\Users\ce\AppData\Local\Programs\Python\Python37\lib\site-packages\django-2.2.4-py3.7.egg\django\core\management\__init__.py",
line 375, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "C:\Users\ce\AppData\Local\Programs\Python\Python37\lib\site-packages\django-2.2.4-py3.7.egg\django\core\management\base.py", line
323, in run_from_argv
self.execute(*args, **cmd_options)
File "C:\Users\ce\AppData\Local\Programs\Python\Python37\lib\site-packages\django-2.2.4-py3.7.egg\django\core\management\base.py", line
364, in execute
output = self.handle(*args, **options)
File "C:\Users\ce\AppData\Local\Programs\Python\Python37\lib\site-packages\django-2.2.4-py3.7.egg\django\core\management\base.py", line
83, in wrapped
res = handle_func(*args, **kwargs)
File "C:\Users\ce\AppData\Local\Programs\Python\Python37\lib\site-packages\django-2.2.4-py3.7.egg\django\core\management\commands\makem
igrations.py", line 141, in handle
loader.project_state(),
File "C:\Users\ce\AppData\Local\Programs\Python\Python37\lib\site-packages\django-2.2.4-py3.7.egg\django\db\migrations\loader.py", line
324, in project_state
return self.graph.make_state(nodes=nodes, at_end=at_end, real_apps=list(self.unmigrated_apps))
File "C:\Users\ce\AppData\Local\Programs\Python\Python37\lib\site-packages\django-2.2.4-py3.7.egg\django\db\migrations\graph.py", line
315, in make_state
project_state = self.nodes[node].mutate_state(project_state, preserve=False)
File "C:\Users\ce\AppData\Local\Programs\Python\Python37\lib\site-packages\django-2.2.4-py3.7.egg\django\db\migrations\migration.py", l
ine 87, in mutate_state
operation.state_forwards(self.app_label, new_state)
File "C:\Users\ce\AppData\Local\Programs\Python\Python37\lib\site-packages\django-2.2.4-py3.7.egg\django\db\migrations\operations\model
s.py", line 668, in state_forwards
model_state = state.models[app_label, self.name_lower]
KeyError: ('TestModel', 'category')
这是由于我之前修改models内的class名称,已经在表单中,
展开migrations,会看到底下很多生成的,打开最后几个,会发现有old_name之类,因为变更名字产生的。
把含models中你想改的那些表单全删掉。或者把这些全部删掉。
然后再 python manage.py makemigrations
就会重新生成表单
- RuntimeError: Model class apps.news.models.NewsCategory doesn't declare an explicit app_label
- RuntimeError: Model class meiduo.apps.users.models.User doesn’t declare an explicit app_label and is
- RuntimeError: Model class meiduo.apps.users.models.User doesn’t declare an explicit app_label and is
- RuntimeError: Model class myapp.models.Test doesn't declare an explicit app_label and isn't in an ap...
- RuntimeError: Model class models.Seller doesn't declare an explicit app_label and isn't in an applic
- RuntimeError: Model class user.models.UserAccount doesn't declare an explicit app_label
- RuntimeError: Model class meiduo_mall.apps.users.models.User doesn't declare an explicit app_label a
- 关于DjangoRuntimeError: Model class doesn't declare an explicit app_label
- android:label="@string/app_name"> 的含义
- Manifest merger failed : Attribute application@label value=(@string/app_name)
- Manifest merger failed : Attribute application@label value=(@string/app_name)
- model class django.contrib.contenttypes.models.contenttype doesn't declare an explicit app_label and
- Django 中related_name,"%(app_label)s_%(class)s_related"
- android:label="@string/app_name" 的作用
- Django报错解决:RuntimeError: Model class ...apps... doesn't declare an explicit app_label and isn't in a
- Django报错提示 "INSTALLED_APPS." % (module, name) RuntimeError: Model class apps.users.models.User do
- 使用Django开发一个图书管理系统----04.通过admin模块管理我们的app和model
- Error: "app_name" is not translated in "zh" (Chinese) [MissingTranslation]
- [Hyperapp] Interact with the State Object through Hyperapp Action functions
- MFC的模块状态:从AfxGetApp()和AFX_MANAGE_STATE()看MFC的模块状态