Question

Django One Click Install not using project folder?

I get a 502 Gateway error on the webpage.

So I checked the Gunicorn log file at /var/log/upstart/gunicorn.log and I got an import error.

ImportError: No module named django_project.wsgi

Which is odd that it is using the django_project folder as I have configured everything to a folder named ProjectStar in the /home/django folder.

/etc/nginx/sites-enabled/django

upstream app_server {
    server 127.0.0.1:9000 fail_timeout=0;
}

server {
    listen 80 default_server;
    listen [::]:80 default_server ipv6only=on;

    root /usr/share/nginx/html;
    index index.html index.htm;

    client_max_body_size 4G;
    server_name _;

    keepalive_timeout 5;

    # Your Django project's media files - amend as required
    location /media  {
        alias /home/django/ProjectStar/media;
    }

    # your Django project's static files - amend as required
    location /static {
        alias /home/django/ProjectStar/static;
    }
}

And the /etc/init/gunicorn.conf file

description "Gunicorn daemon for Django project"

start on (local-filesystems and net-device-up IFACE=eth0)
stop on runlevel [!12345]

setuid django
setgid django
chdir /home/django

exec gunicorn \
    --name=ProjectStar \
    --pythonpath=ProjectStar \
    --bind=0.0.0.0:9000 \
    --config /etc/gunicorn.d/gunicorn.py \
    django_project.wsgi:application

I have tried restarting and stopping nginx and gunicorn but the error in the log does not change. Please help.

Show comments

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.

Want to learn more? Join the DigitalOcean Community!

Join our DigitalOcean community of over a million developers for free! Get help and share knowledge in Q&A, subscribe to topics of interest, and get courses and tools that will help you grow as a developer and scale your project or business.

I found the solution to my problem: edit /etc/init/gunicorn.conf and change django_project.wsgi:application to my_app.wsgi:application (to match what’s in settings.py).

Maybe this is what was wrong with your setup as well.

yes u need to do changes in settings.py as well as wsgi.py

Check the settings.py file for the project. Did you start by copying the one from the default project? It likely still contains the line:

WSGI_APPLICATION = 'django_project.wsgi.application'