Question

django app can't find wsgi file

I’m trying to deploy a Django site on the app platform. It keeps failing with:

ModuleNotFoundError: No module named 'thesite.wsgi'

I started the project with django-admin startproject thesite

My run command for the app is gunicorn --worker-tmp-dir /dev/shm thesite.wsgi

And if I run that command from the project root (the same location as manage.py) on my local machine, everything works.

Any thoughts? I suspect that this is something related to the context where the gunicorn command is running, but I can’t figure out how to get a shell in the same VM/container/whatever that the app is hosted in.


Submit an answer


This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Bobby Iliev
Site Moderator
Site Moderator badge
April 14, 2023

Hi there,

There are a couple of things that I could suggest here:

  • Make sure you have a requirements.txt or Pipfile in your project’s root directory, listing all the dependencies, including gunicorn. The app platform will use this file to install the required packages.

  • Ensure that your directory structure is correct. It should look like this:

your-repo/
    manage.py
    thesite/
        __init__.py
        settings.py
        urls.py
        wsgi.py
  • In the app platform settings, ensure that your Source Directory is set correctly. If your manage.py and the inner thesite directory are in the root of your repository, leave the Source Directory field empty or set it to /.

After try force redeploying your Django app on the app platform.

On another note, here is an example Django project which you could use as a reference:

https://github.com/digitalocean/sample-django

Let me know how it goes!

Best,

Bobby

Try DigitalOcean for free

Click below to sign up and get $200 of credit to try our products over 60 days!

Sign up

card icon
Get our biweekly newsletter

Sign up for Infrastructure as a Newsletter.

Sign up
card icon
Hollie's Hub for Good

Working on improving health and education, reducing inequality, and spurring economic growth? We’d like to help.

Learn more
card icon
Become a contributor

You get paid; we donate to tech nonprofits.

Learn more
Welcome to the developer cloud

DigitalOcean makes it simple to launch in the cloud and scale up as you grow – whether you’re running one virtual machine or ten thousand.

Learn more ->
DigitalOcean Cloud Control Panel