Report this

What is the reason for this report?

Django One Click Install not using project folder?

Posted on August 8, 2014

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.



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!

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.

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.

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'

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

The developer cloud

Scale up as you grow — whether you're running one virtual machine or ten thousand.

Get started for free

Sign up and get $200 in credit for your first 60 days with DigitalOcean.*

*This promotional offer applies to new accounts only.