2024-04-15T10:19:48.1687992Z AttributeError: module 'django.conf.global_settings' has no attribute 'ROOT_URLCONF' when even though the settings.py file has ROOT_URLCONF present ?

Sayak Dasgupta 25 Reputation points
2024-04-15T10:32:55.63+00:00

Trying to run my django app on the Azure web app services, getting the error 2024-04-15T10:19:48.1687992Z AttributeError: module 'django.conf.global_settings' has no attribute 'ROOT_URLCONF' in the log files even though it runs perfectly on the localhost and has the ROOT_URLCONF present in the settings.py file

Azure App Service
Azure App Service
Azure App Service is a service used to create and deploy scalable, mission-critical web apps.
6,930 questions
{count} vote

Accepted answer
  1. Stefan Niederberger 90 Reputation points
    2024-04-17T10:49:12.92+00:00

    Here I post my solution from the comment section:

    "I investigated the issue and found that web app tries to start the Django application before loading the DJANGO_SETTINGS_MODULE variable into os environment causing the URL_CONF parameter not beeing available. As a quick fix, I added DJANGO_SETTINGS_MODULE manually to the environment. Now, all my web app instances work again as expeced. I hope this helps for you too."

    Please vote/accept this answer that others can find the proposed solution more easily!

    2 people found this answer helpful.

1 additional answer

Sort by: Most helpful
  1. ajkuma 22,436 Reputation points Microsoft Employee
    2024-04-16T10:17:29.3066667+00:00

    @Sayak Dasgupta , Thanks for posting this question.

    I understand, the app runs perfectly on the localhost/locally.

    If your WSGI callable in your wsgi.py file is not named application. Just verify,

      app = get_wsgi_application()
    

    If you haven't done this already, : Oryx looks for a wsgi.py file and within it an wsgi callable named application by default for Django. If you decide to name your WSGI callable something not named application, you will need to change your startup command to target this appropriately. The example below assumes you have a file named wsgi.py with a WSGI callable named app inside of it in your mysite (or your relevant main Django app directory):

    gunicorn --bind 0.0.0.0:8000 --timeout 600 mysite.wsgi:app
    
    
    

    See this doc Django Deployment on App Service Linux for more info.

    I'm also reaching out to you privately to fetch additional info about your resources for further investigation.