Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Gunicorn ImportError: No module name myApp

I am trying to deploy my code on Heroku but gunicorn is giving error ImportError: No module named inventory.

My Directory Structure

--server
  |
  |--server
    ├── __init__.py
    ├── home
    │   ├── __init__.py
    │   ├── admin.py
    │   ├── migrations
    │   │   ├── __init__.py
    │   ├── models.py
    │   ├── tests.py
    │   ├── views.py
    ├── inventory
    │   ├── __init__.py
    │   ├── admin.py
    │   ├── migrations
    │   │   ├── 0001_initial.py
    │   │   ├── __init__.py
    │   ├── models.py
    │   ├── serializer.py
    │   ├── tests.py
    │   ├── views.py
    ├── manage.py
    └── server
        ├── __init__.py
        ├── settings.py
        ├── urls.py
        ├── wsgi.py

wsgi.py

import os

from django.core.wsgi import get_wsgi_application
from whitenoise.django import DjangoWhiteNoise

os.environ.setdefault("DJANGO_SETTINGS_MODULE", "server.server.settings")

application = get_wsgi_application()
application = DjangoWhiteNoise(application)

Basically my main server Django project is in /server/server/settings.py Need Help here

like image 334
Naresh Avatar asked Dec 20 '25 11:12

Naresh


1 Answers

The DJANGO_SETTINGS_MODULE parameter should be set from the root of your project, that should be:

os.environ.setdefault("DJANGO_SETTINGS_MODULE", "server.settings")

like image 75
Miki Torandell Avatar answered Dec 22 '25 23:12

Miki Torandell



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!