我正在为该项目进行此安装: https://github.com/IntelligentTrading/data
项目使用设置文件夹而不是settings.py文件。 (例如,与未找到设置文件相比,此错误非常独特)。来自settings / vendor_services_settings.py的数据是需要的并导致错误。迁移命令似乎只在settings / local_settings.py文件中查找。
我已经准备好迁移:(我在virtualenv中)
python manage.py migrate
INFO:settings:Deployment environment detected: LOCAL
INFO:settings:Importing vendor_services_settings
INFO:settings:LOCAL environment detected. Importing local_settings.py
Traceback (most recent call last):
File "manage.py", line 22, in <module>
execute_from_command_line(sys.argv)
File "/home/cerulean/.virtualenvs/ITF/lib/python3.6/site-packages/django/core/management/__init__.py", line 381, in execute_from_command_line
utility.execute()
File "/home/cerulean/.virtualenvs/ITF/lib/python3.6/site-packages/django/core/management/__init__.py", line 357, in execute
django.setup()
File "/home/cerulean/.virtualenvs/ITF/lib/python3.6/site-packages/django/__init__.py", line 24, in setup
apps.populate(settings.INSTALLED_APPS)
File "/home/cerulean/.virtualenvs/ITF/lib/python3.6/site-packages/django/apps/registry.py", line 112, in populate
app_config.import_models()
File "/home/cerulean/.virtualenvs/ITF/lib/python3.6/site-packages/django/apps/config.py", line 198, in import_models
self.models_module = import_module(models_module_name)
File "/home/cerulean/.virtualenvs/ITF/lib/python3.6/importlib/__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 994, in _gcd_import
File "<frozen importlib._bootstrap>", line 971, in _find_and_load
File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 665, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 678, in exec_module
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "/home/cerulean/Code/data-sources/apps/indicator/models/__init__.py", line 5, in <module>
from apps.indicator.models.events_elementary import EventsElementary
File "/home/cerulean/Code/data-sources/apps/indicator/models/events_elementary.py", line 17, in <module>
from apps.signal.models.signal import Signal
File "/home/cerulean/Code/data-sources/apps/signal/models/__init__.py", line 1, in <module>
from apps.signal.models.signal import Signal
File "/home/cerulean/Code/data-sources/apps/signal/models/signal.py", line 15, in <module>
from settings import QUEUE_NAME, AWS_OPTIONS, BETA_QUEUE_NAME, TEST_QUEUE_NAME, PERIODS_LIST
ImportError: cannot import name 'QUEUE_NAME'
在/settings/local_settings.py的第21行上,它表示如果包含'LOCAL',则传递此数据,而不是像if语句中的其他情况一样传递所需的数据:
else: # LOCAL
pass # see local_settings.py
尽管在settings / init .py的第28行上,该代码似乎专门用于指示程序将环境类型设置为local。
dt_key = os.environ.get('DEPLOYMENT_TYPE', 'LOCAL')
几乎就像/settings/vendor_services_settings.py中的代码不想导出其代码一样,因为该程序在本地环境中运行。我尝试将代码从该vendor_service_settings.py文件添加到local_settings.py文件,该文件可以工作到程序似乎需要实际数据为止。
BUCKET_NAME = "intelligenttrading-s3-production"
QUEUE_NAME = "intelligenttrading-sqs-production" # for production bot
# DELAYED_QUEUE_NAME = "intelligenttrading-delayed-sqs-production"
BETA_QUEUE_NAME = "intelligenttrading-sqs-beta" # for beta bot
TEST_QUEUE_NAME = ""
SNS_NAME = "intelligenttrading-sns-production"
将此代码“ Shivving”到local_settings.py文件中使迁移暂时起作用,尽管这仍然不是解决方案。我想我的问题是,如何在Django的settings文件夹中的各个文件之间正确导入数据?
我认为只部署一个Amazon Aurora数据库实例,因为它可能会注册为生产环境。虽然教程会让我事先运行相同的python manage.py迁移代码,但无论如何。服务器部署会有所作为吗?