我有一个settings.py文件,必须向它添加以下whitenoise代码。Whitenoise只是简化了我的django应用程序的静态文件的部署。
import socket
STATICFILES_STORAGE = 'whitenoise.storage.CompressedManifestStaticFilesStorage'
STATIC_ROOT = os.path.join(BASE_DIR, "static")
STATIC_URL = "/static/"
if socket.gethostname() =="your_laptop_hostname_goes_here":
DATABASES["default"]["HOST"] = "localhost"
DATABASES["default"]["PORT"] = docker_config.POSTGIS_PORT
else:
DATABASES["default"]["HOST"] = f"{docker_config.PROJECT_NAME}-postgis"
DATABASES["default"]["PORT"] = 5432
# Set DEPLOY_SECURE to True only for LIVE deployment
if docker_config.DEPLOY_SECURE:
DEBUG = False
TEMPLATES[0]["OPTIONS"]["debug"] = False
# ALLOWED_HOSTS = ['.your-domain-name.xyz', 'localhost',]
CSRF_COOKIE_SECURE = True
SESSION_COOKIE_SECURE = True
else:
DEBUG = True
TEMPLATES[0]["OPTIONS"]["debug"] = True
ALLOWED_HOSTS = ['*', ]
CSRF_COOKIE_SECURE = False
SESSION_COOKIE_SECURE = False我还必须使用布尔变量创建一个docker_config.py文件,我已经这样做了。我尝试使用以下方法将文件导入到我的settings.py中:
from geodjango import docker_config在运行之后,我得到了标题中描述的错误:
python manage.py migrations我的项目文件夹如下所示:

发布于 2020-11-07 19:15:07
试着替代
from geodjango import docker_config使用
from geodjango.world import docker_confighttps://stackoverflow.com/questions/64720250
复制相似问题