How do I make my droplet run Django from my virtualenv?

January 31, 2015 9.2k views

I did the 1-click Ubuntu/Django install. I'm trying however to run my Django project I migrated over which is contained within a virtualenv. Is there a config file with wsgi or nginx I need to edit to "point" it at virtualenv? I currently have my project migrated over but when I visit the IP for the droplet, all I see is the generic "congratulations on your first django page" message. What am I doing wrong?

  • Where does the 1-click install put the uwsgi.ini file?

  • Did you ever figure this out. I'm having the same issues.

  • first pip install guinicorn into your virtualenv

    Then you need to edit /etc/init/guincorn.conf to point to your project and the gunicorn in your virtualenv.

    It is also important to note that if you have any environment variables in your django project they need to be included in the .conf as well


    description "Start Gunicorn Daemon for Forte Project"
    author "Jeffrey Balinsky"
    start on (filesystem)
    stop on runlevel [016]
    env TEMPLATE_DIR=/home/django/forte/templates
    env STATIC_DIR=/home/django/forte/static
    env DBUSR=django
    env DBPW=*******
    chdir /home/django/forte
    exec /home/django/prod/bin/gunicorn \
        --bind= \
  • Thanks for that.

    I'm guessing /home/django/forte is your project folder and /home/django/prod your virtualenv?

    I just get the following when restarting gunicorn

    stop: Unknown instance:
    start: Job failed to start

  • you guessed right

    i forgot to mention when you change the .conf file you have to run:

    initctl reload-configuration


    restart gunicorn

  • Thanks for the help Jeffrey. I now have gunicorn restarting but get a 502 bad gateway error. I'll get there eventually. All I want is the latest Django running on Python 3. You wouldn't think it would be this difficult.

  • No solution?? I met the same problem, and ask with no usefulI answer come back, just wonder is there an solution? Or digitalOcean does not support

  • Yes, I did eventually figure it out. I need to go over the steps again to make sure I can replicate it. I will post the steps when I get chance. It would be nice if Digital Ocean could offer an updated 1-click Django install with Python 3.

  • i am having the same issue, i haven been able to make my project run using virtualenv python3 and django1.7.7

2 Answers

Sorry to see that your question hasn't received an answer yet. Unfortunately, after this much time, it is unlikely that an answer for this specific question will be provided. For people still landing here via search, check out this updated tutorial set up Django using a virtualenv:

by Jeremy Morris
In this tutorial, we will set up a Django development environment. We’ll install Python 3, pip 3, Django and virtualenv in order to provide you with the tools necessary for developing web applications with Django.
Have another answer? Share your knowledge.