Skip to content
Home » django.core.exceptions.ImproperlyConfigured: Requested setting ROOT_URLCONF, but settings are not configured.

django.core.exceptions.ImproperlyConfigured: Requested setting ROOT_URLCONF, but settings are not configured.

To solve the django.core.exceptions.ImproperlyConfigured: Requested setting ROOT_URLCONF, but settings are not configured. You must either define the environment variable DJANGO_SETTINGS_MODULE or call settings.configure() before accessing settings. Follow the below methods:

Method 1: Instead of using django-admin, it is probably easier to use manage.py

python3 manage.py <command>

Method 2: If you want to use the django-admin, then try the below code.

export PYTHONPATH=/home/name/project_path
export DJANGO_SETTINGS_MODULE=my_project.settings
django-admin <command>

If you’re running a server on Heroku, though, you’ll need to mention it there as well. As an example:

heroku config:set DJANGO_SETTINGS_MODULE=mysite.settings --account <your account name>

Putting all together,

export DJANGO_SETTINGS_MODULE=site_name.settings
heroku config:set DJANGO_SETTINGS_MODULE=site_name.settings --account personal

Also Look :

Model class django.contrib.sites.models.Site doesn’t declare an explicit app_label and isn’t in an application in INSTALLED_APPS

Tags: