报错信息:
Traceback (most recent call last): File "D:/workspace/Mxshop/db_tools/import_category_data2.py", line 14, in <module> django.setup() File "D:\Envs\VueShop\lib\site-packages\django\__init__.py", line 22, in setup configure_logging(settings.LOGGING_CONFIG, settings.LOGGING) File "D:\Envs\VueShop\lib\site-packages\django\conf\__init__.py", line 56, in __getattr__ self._setup(name) File "D:\Envs\VueShop\lib\site-packages\django\conf\__init__.py", line 41, in _setup self._wrapped = Settings(settings_module) File "D:\Envs\VueShop\lib\site-packages\django\conf\__init__.py", line 110, in __init__ mod = importlib.import_module(self.SETTINGS_MODULE) File "D:\Envs\VueShop\lib\importlib\__init__.py", line 126, in import_module return _bootstrap._gcd_import(name[level:], package, level) File "<frozen importlib._bootstrap>", line 978, in _gcd_import File "<frozen importlib._bootstrap>", line 961, in _find_and_load File "<frozen importlib._bootstrap>", line 948, in _find_and_load_unlocked ModuleNotFoundError: No module named 'Mxshop.settings'
manage.py
if __name__ == "__main__": os.environ.setdefault("DJANGO_SETTINGS_MODULE", "Mxshop.settings")
import_category_data.py
import sys import os pwd = os.path.dirname(os.path.realpath(__file__)) sys.path.append(pwd+"../") os.environ.setdefault("DJANGO_SETTINGS_MODULE", "Mxshop.settings") # 初始化django import django django.setup()
Django REST framework课程视频,RESTFul API前后端分离开发
了解课程