What is the best Workflow for Updating a Web App - django

I'm pretty new at this but I recently deployed my first web application using Django, Postgres, Nginx, and Gunicorn on Digital Ocean.
I went to make some updates and ran sudo service gunicorn restart to see the changes. I wiped my entire Database. I obviously need to work on setting up a better workflow for deploying to production.
Does anyone have any suggestions? What are some best practises when re-deploying a Django App with a Postgres DB? I've read some articles about backing up my DB (which I'm definitely going to be doing in future), but what else can be done to ensure a seem-less transition?

Related

how to do makemigrations/migrate in gnadi(python/postgresql web hebergement)

I am a python developer and new to GANDI (python/PostgreSQL web hosting). There is no document to migrate databases to their server. they have their document to deploy a Project Django but not very clear there are a lot of things missing. After taking a lot of time on the internet, I managed to deploy a Django project in their server. The site works smoothly with an SQLite database. Now I would like to make a Django Project with PostgreSQL. I have an emergency console, but I would like to work locally and then I would like to migrate the DBs to their phpPGadmin server. I just need your help to do makemigrations/migrate to thier PostgreSQL(PhpPGadmin) server. Thanks in advance.

How do I prevent my Django Database from being overwritten

Currently I have a Django application running on my personal website from PythonAnywhere.com. When I make updates to the site I login to PythonAnywhere and git pull to update my application. When I do this the data that was entered through the website since the last update gets lost from the database when I update. What can I do to overcome this?
I am currently using the SqlLite version that comes preinstalled with the Django App. This likely could be part of the issue but need some help understanding how to overcome it.
I presume that your Django project is connecting to the SQLite database that gets generated when you create a new project and you are pushing that database in your deployment. That database won't be suitable for production and won't retain your changes, you instead need to setup a database that your application can connect to.
Here is some information on PythonAnywhere about databases:
https://help.pythonanywhere.com/pages/KindsOfDatabases/
And the Django documentation:
https://docs.djangoproject.com/en/4.0/ref/databases/

When deploying updated Django code on server, the database resets

I have built an app which uses Django as a Rest API (Django rest framework). After having deployed the code on digital ocean using production grade services, everything works well. The postgresql database populates itself correctly . There is no reset of the server like on Heroku.
Except, if I change a file and push the change through gitlab(Digital ocean picks up the change and automatically deploys the updated version of the server), the database resets to its original state. I would like the server to stay as.
I have removed all migration files before pushing updates, but to no avail. I imagine it has to be something rather trivial but I can't find it.
The database is hosted also by digital ocean. I havent done any configuration. Wouldn't it be managed automatically as DO deploys the code on its servers?
I figured out what went wrong. Using the sqlite db while developping is one thing, but assuming when deploying your django app on a service provider that it will handle the whole db management is a 1000 steps too far.
Logically, whenever I pushed a new update to the server, the db would reset using the sqlite local db file of the project.
So I created a specific db on digital ocean, change the database config on the settings file of my django project to connect to it. Making the project use the external db. then I Just had to migrate project db structure to the external db.
And Voila. problem resolved

How to get users back after deploying Django App to Heroku [duplicate]

I want to deploy an application with sqlite3 as the database on Heroku. However, it seems to be that Heroku doesn't support applications with sqlite3 as the database. Is it true? Is there no way to deploy my sqlite3-backed application on Heroku?
PS: I have successfully deployed my application using PythonAnywhere, but would now like to know whether there's any possible way to deploy it using Heroku.
As Heroku's dynos don't have a filesystem that persists across deploys, a file-based database like SQLite3 isn't going to be suitable. It's a great DB for development/quick prototypes, though.
Heroku do have a Postgres offering however that will suit - with a free tier and a basic $9/month tier that are good for hobby/small projects. The biggest benefit over SQLite is that you get backups that you wouldn't get otherwise (plus all the other Postgres features).
There's a guide to updating your settings.py to use Postgres here: https://devcenter.heroku.com/articles/getting-started-with-django#django-settings
Heroku has a detailed article explaining "Why is SQLite a bad fit for running on Heroku" https://devcenter.heroku.com/articles/sqlite3

heliohost and django hosting and deployment from bitbucket

I'm new to Django and Heliohost and Heroku.
I don't see any guides online to setup and deploy a Django project from bitbucket for Heliohost. Can you guys point me in the right direction?
And I was wondering is hosting a Django project on Heroku free for small projects?
Should I switch from Heliohost to Heroku?
Thanks everybody. I appreciate your help.
I've hosted multiple small (free-heroku) projects with Heroku and Django - They work very well together. Especially if you don't have a lot of server experience.
Heroku has a straightforward django guide, and using git with your projects to push local changes into heroku is fast/easy.
Heroku has lots of plugins (many for free) that can help out even the smallest django application running on the free level. Memcache is a must, to keep your small apps running as quickly as possible.
All in all Heroku is a great way to host a Django Powered application, it's instantly scale-able when your application is ready to grow, but works well enough in the free capacity in order to let it grow !