Saving Changes To Django with Nginx?

2019-09-06 00:12发布

问题:

Anything I modify on my Django app has no effect with what's live on the webapp itself. I can delete the entire project directory and my Django app still works.

With Django and Apache, I would simply enter:

/etc/init.d/apache2 restart

And any changes made to my Django application would go live immediately after Apache was restarted. But with this new Nginx, the same thing doesn't work:

/etc/init.d/nginx restart

My Django home page still shows the:

It worked! Congratulations on your first Django-powered page.

How do I make my Python changes go live with Django and nginx?

回答1:

What is your Nginx configuration? What is your WSGI runner, are you using Nginx-wsgi or the inbuilt Django 'runserver' command?

It sounds like the "it worked" page is on a separate port, and you're testing it directly -- not via Nginx. It's really easy to get the two of them confused :)



回答2:

Nvm just figured it out. For Django One Click Install Image on Digital Ocean you need to run:

service gunicorn restart

After you've made all the changes and you'd like to test changes to your web app.