djangodockerpycharmwhitenoise

ImportError: cannot import name 'docker_config' from 'geodjango'


I have a settings.py file that I must add the following whitenoise code to it. Whitenoise is just simplifying the deployment of static files for my django application.

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

I also have to create a docker_config.py file with a boolean variable which I have done so. I try to import the file to my settings.py using:

from geodjango import docker_config

And I get the described error in the title after I run:

python manage.py migrations

My project folder looks like this:

enter image description here


Solution

  • Try to substitute

    from geodjango import docker_config
    

    with

    from geodjango.world import docker_config