Saving Changes To Django with Nginx? - python

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?

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 :)

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.

Related

django - Changes in template files are not shown

I'm working on a django project, after changing some templates, it works on my local machine, but after uploading to production server (+restarting Apache) webserver shows the old code!
Its about few specific base template files.
I have tried to restart server, reload webserver and reinstall venv.
None of it worked.
Do I use template/fragment caching? No.
Do I use apache's caching? No.
UPDATE :
i just made some changes to one of another app's template files and uploaded it
after refresh, it updated right away!
now i am pretty sure that this problem is happening to only 1 of my apps
In my case, using gunicorn, I solved it this way:
sudo systemctl restart gunicorn-django-tutorial.service
The changes are not shown in production because gunicorn needs to reload the configuration.
A restart of the web server is not needed (I'm using Nginx).

Django settings.py not updating on production

I have a server that is live right now, there is some SMTP stuff I want to change the settings.py of my Django project. I have made the changes, however, I cannot get the server to detect the changes, and it throws a SMTPAuthentication error because the settings.py is still using the old settings.
The server is set up with nginx, and I have tried service nginx reload several times, and apachectl restart several times. As well as deleting any *.pyc files.
nginx cannot be actually running the site, as it is not a WSGI server. Presumably it is running as a proxy to something like gunicorn or uWSGI; it is those that you need to restart.
Autoreload in production is not good idea, but if you understand what you do, you can use additional python module for autoreloading or use additional param for uwsgi. Django devel autoreloading not works with uwsgi.

Django under supervisord?

django project is running under supervisord, when i try to edit the html templates, nothing changes in the web site, should I restart the supervisord or is there other easier way to make changes to the project?

Django: Push app from local server to production server via FTP

This is a bit embarassing, but I'm a Django noob and I couldn't find a simple solution to this:
I have written a Django app in a local VM that I now want to deploy to a "production" server. App works like a charm locally.
Now my IT colleague has set up the server with Django and that also works fine. I can open it via the Web and I get the usual "Congratulations on your first Django-powered page". I can also log into the admin interface. The project has been created.
This is a very low-key mini project and I'm not too familiar with git, so we've decided to just push files via FTP. (And I want to stick with that if at all possible.) So I uploaded the app folder into the project folder and also adjusted the project's settings.py and urls.py.
However, nothing seems to be happening on the server's end. The welcome page is the same, the app does not show up in the admin interface and the URLs won't be resolved as hoped.
Any suggestions what I should have done / done differently?
You need to restart apache or whatever is running your django project. Your changes to py files are cached when you first load your server config (settings).
Any suggestions what I should have done / done differently?
You should be using git/jenkins/deployment techniques, I know you said you've decided not to use it but you're going to be missing out on important things like being able to keep track of changes and unit testing

how to set django development server

I am stuck on this step:
i have a page, which i am developing in django. the page is ready to test. i deployed it. running well and it is online. but now i want to setup a new project in server as the testing version of what is online now. I went to control panel of my hosting provider and saw that once i created the django project first, it also created a new dev.mypage.com. But i cannot find this in my server. i dont know how to setup a new dev project in server so that i can develop locally, push to test project and test online and then go live.
please help
You may like to use nginx + gunicorn (http://docs.gunicorn.org/en/latest/run.html). Also, http://senko.net/en/django-nginx-gunicorn/ is useful.

Categories

Resources