Reputation: 1734
I have made a django web app using the default localhost, however I am trying to set it up on a server so that I can configure a postgre database and continue on without having to redo the database later on.
I am hosting the site though a digital ocean ubuntu 14 droplet. When I created the droplet I selected that it already come preconfigured for django. It uses nginx and gunicorn to host the site.
When I first created the instance of the server, a basic django app was configured to work on the given IP. And it did.
I tried cloning my project into the same directory as that project assuming it would live on the python path ('/home/project') and configured the nginx to serve up 127.0.0.1:8000 per some of the documentation I found.
I believe the issue lies in when I try to bind gunicorn. I get the following error with this input.
gunicorn -b 127.0.0.1:8000 GenericRestaurantSystem/wsgi.py:application
ImportError: Failed to find application, did you mean 'program/wsgi:application'?
I am not 100% sure, but it seems as though gunicorn is not serving up anything (or not even on) at this point.
Any suggestions as to binding this application successfully?
Upvotes: 15
Views: 21217
Reputation: 1
Create file in root you_django_name_project "main.py":
from you_django_name_project.wsgi import application
app = application
And run:
gunicorn -b 127.0.0.1:8000 main:app
Upvotes: 0
Reputation: 8481
I had the same problem and got it to work with this:
gunicorn -b 127.0.0.1:8000 wsgi:application
I put the wsgi.py
file at the same level as manage.py
.
Upvotes: 1
Reputation: 2902
for me this work like charm :)
cd ~/myproject
gunicorn —bind 0.0.0.0:8000 myproject.wsgi:application
Upvotes: 1
Reputation: 1082
I guess it should be
gunicorn GenericRestaurantSystem.wsgi:application
Upvotes: 6
Reputation: 599946
Well that's not how you refer to the WSGI file with gunicorn. See the docs:
The module name can be a full dotted path. The variable name refers to a WSGI callable that should be found in the specified module.
So if your wsgi.py file is in GenericRestaurantSystem/wsgi.py, your command should be
gunicorn -b 127.0.0.1:8000 GenericRestaurantSystem.wsgi:application
Upvotes: 37