Ylisen / dailyfresh-B2C

dailyfresh mall based on B2C model
228 stars 162 forks source link

在任务处理者worker一端加以下几句如何理解 #3

Open scjmanbuman opened 5 years ago

scjmanbuman commented 5 years ago

你好,

我这边环境是windows server ,如何理解下面的注释呢? 目前我注册没有响应, 单独跑task.py 出错

django环境的初始化,在任务处理者worker一端加以下几句

import os

import django

os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'dailyfresh.settings')

django.setup()

C:\python37\python.exe C:/Users/Administrator/dailyfresh-B2C-master/dailyfresh/celery_tasks/tasks.py Traceback (most recent call last): File "C:/Users/Administrator/dailyfresh-B2C-master/dailyfresh/celery_tasks/tasks.py", line 15, in from apps.goods.models import GoodsType, IndexGoodsBanner, IndexPromotionBanner, IndexTypeGoodsBanner File "C:\Users\Administrator\dailyfresh-B2C-master\dailyfresh\apps\goods\models.py", line 3, in from db.base_model import BaseModel File "C:\Users\Administrator\dailyfresh-B2C-master\dailyfresh\db\base_model.py", line 12, in class BaseModel(models.Model): File "C:\python37\lib\site-packages\django\db\models\base.py", line 103, in new app_config = apps.get_containing_app_config(module) File "C:\python37\lib\site-packages\django\apps\registry.py", line 252, in get_containing_app_config self.check_apps_ready() File "C:\python37\lib\site-packages\django\apps\registry.py", line 134, in check_apps_ready settings.INSTALLED_APPS File "C:\python37\lib\site-packages\django\conf__init.py", line 79, in getattr__ self._setup(name) File "C:\python37\lib\site-packages\django\conf__init__.py", line 64, in _setup % (desc, ENVIRONMENT_VARIABLE)) django.core.exceptions.ImproperlyConfigured: Requested setting INSTALLED_APPS, but settings are not configured. You must either define the environment variable DJANGO_SETTINGS_MODULE or call settings.configure() before accessing settings.

Process finished with exit code 1