run manage.py Task报错

来源:3-6 migrations原理及表生成

加菲3721

2018-09-25

输入正文 Failed to get real commands on module "MxShop": python process died with code 1: Traceback (most recent call last): File "D:\PyCharm 2018.2.3\helpers\pycharm\_jb_manage_tasks_provider.py", line 25, in django.setup() File "E:\MxShop\venv\lib\site-packages\django\__init__.py", line 24, in setup apps.populate(settings.INSTALLED_APPS) File "E:\MxShop\venv\lib\site-packages\django\apps\registry.py", line 112, in populate app_config.import_models() File "E:\MxShop\venv\lib\site-packages\django\apps\config.py", line 198, in import_models self.models_module = import_module(models_module_name) File "C:\Python37\lib\importlib\__init__.py", line 127, in import_module return _bootstrap._gcd_import(name[level:], package, level) File "", line 1006, in _gcd_import File "", line 983, in _find_and_load File "", line 967, in _find_and_load_unlocked File "", line 677, in _load_unlocked File "", line 728, in exec_module File "", line 219, in _call_with_frames_removed File "E:\MxShop\apps\user_operation\models.py", line 6, in from goods.models import Goods File "E:\MxShop\apps\goods\models.py", line 9, in class GoodsCategory(models.Model): File "E:\MxShop\apps\goods\models.py", line 24, in GoodsCategory related_name="sub_cat") TypeError: __init__() missing 1 required positional argument: 'on_delete' 我的环境Python3.7 Django2.1.1
写回答

1回答

bobby

2018-09-26

你使用django2的话 你需要给每个model的外键上添加on_delete 属性 //img.mukewang.com/szimg/5bab19610001cc7508340068.jpg

1
0

Python前后端分离开发Vue+Django REST framework实战

Django REST framework课程视频,RESTFul API前后端分离开发

2873 学习 · 2457 问题

查看课程