How to migrate a Django app with postgres database - django

I have just inherrited a jDango app with .tar.gz compression extention and a .sql file which is a postgreSQL database dump. My mission which I did not choose to accept is to somehow find its way onto AWS. I'm not familier with Django. I believe the app was built with the Ubuntu OS.
I thought that maybe the best thing would be to get postgreSQL and Django working on my local machine. I have all working in vanilla on Windows, and Ubuntu (virtual box) and have set up Amazon Lightsail with a postgreSQL database..
I'm a bit stuck as to what to do next to migrate the app. Would it all be CLI/Cmd Prompt/Terminal or is there a procedure I should be using.
I'm guessing it's not as simple as importing the database and then copying files over and replacing existing vanilla Django ones? Any pointers would be of great help. Thanks.

Open your editor terminal and write code below:
python manage.py makemigrations
python manage.py migrate

Related

Heroku: installing Postgres without local db | Django

I've already pushed my Django files to Heroku via Git and now I'd like to configure at Heroku server the Postgres database. After that, I need to transfer my local sqlite database to Heroku Postgres.
All of this issue is because I don't have admin rights on my local PC (corporate unit) to install Postgres.
So basically:
1. Configure remotely Postegres at Heroku;
2. Migrate local database (sqlite) to Heroku (Postgres).
I don't know if there is another path to go on...
Thank you!
That's some crazy gymnastics you're trying to do. Getting a grasp of PostgreSQL setup is hard as it is. There are several user/table privileges you have to maintain. Sqlite3 has very simple settings in the settings.py file in Django, while Postgres requires a username, password, Host, and Port.
Also the sql you export from sqlite3, might not ingest directly into the PostgreSQL. See this. You'll have to install Postgres on your local machine, if you plan to have any sort of ok workflow as far as I can see. You can probably explore docker to create a local dev environment on your corporate PC.

How to make a Django server portable?

My web server depends on nginx, django, and a lot of python dependencies. I'm wondering if there is a way to create a portable image/script that I can run in a new server and quickly get it up and running.
Is Docker relevant to this?
You should always use git to manage your code. With git you could get your django project in the other server quickly. But just that.
Also you have to migrate your database. Every DB engine have dump options for doing this.
Do not forget to move your static assests. Probably, you've all of them in one directory.
What about your nginx, database installation and configuration? Here is relevant Docker.
With all of this, you should migrate successfully.

Is it possible to build a portable webapp when using oracle with django

I started developing a django webapp which will need to connect to oracle databases. But using oracle with django requires an Oracle client if I'm not mistaken which is platform dependant. If it's not possible to create a portable webapp with django and oracle, could the app use an oracle client install on the machine where the app is running?
Thanks
What do you mean by "portable" exactly ? You can definitely move your Django folder around, especially if you use SQLite for database storage, since a SQLite database is just a file.
All you'll need is Python on the target machine, access to the command line and the ability to install your dependencies with pip.
Then you can just run your webapp with python manage.py runserver.
If this doesn't answer your question, please give more info.

Connecting to Django shell on Azure Websites

On Heroku, I can connect to a Django shell by running
heroku run python manage.py shell
Is there an equivalent on Azure Websites?
Aha! I realized I can just connect to the database by adding it as an additional database on my local version of the app.
Not exactly what I was thinking of originally, but it seems to solve all of my use cases, for example:
python manage.py syncdb --database=live

How can you access your online postgresql database when developing on your local machine?

I want to start developing a django app on heroku which uses the postgresql database. I already got my hello world django app working on heroku, but now I am wondering how to develop with the postgresql database.
How do people do this? Can I link to the heroku postgresql database in the settings.py and develop on my local 'django runserver' server?
How do people do this? Do they use a postgresql database on their own machine? How would you keep the online one and your local one the same?
I think one of the best way - it is to copy database to your local machine, but it will be hard, if you have got huge database.
You can also use working database from remote server. Just type ip/host and other settings for database on your server and you'll get access.
Not sure about python and how you interact with heroku (do you use the heroku cli??) but in the Ruby land we can do heroku db:pull which will pull the DB from heroku and magically transpose it into whatever DB you use locally, the same for pushes. It also supports individual/combintations of tables to push/pull.