How to store postgresql database in django - project folder? - django

Where is postgreSQL database saved in a django folder (that which has manage.py)?
If not, I presume it must be stored in postgres folder of root directory.
Then, how to transfer this file to those systems having no postgres installed, so that when they run server, they can see seamlessly all the data/app?
Can we ask DJANGO to create the database file in its project folder itself and does this help in such transfers? Thanks.

Related

How to decouple local directory and Heroku project

I am developing an app with Django and I successfully pushed it on Heroku.
This app has a postgres database and a form to allow users to fill the database.
I have coupled the local directory and Heroku, so that both if I run the server by command prompt, or if I access the app, and submit the form, my database get changed.
Now I want to make some experiments on the local database without changing the one on Heroku.
Is it possible?
Can I do it by just commenting the database URL in settings.py ?
I have searched for this matter on Google but I don't know the name it, so that I cound not find proper answer.
This is not a question of "decoupling" directories. It is because you are trying to use sqlite on Heroku, and you have added the sqlite file to your git repo.
You cannot use sqlite on Heroku; use the postgres add-on. Additionally, your sqlite file must not be in source control.

Django - share media files during development

I want developers to use the same development database while developing a Django project so I've created a remote server with Ubuntu 18.04, created Postgres database and allowed remote access.
The problem is that there are missing pictures - media directory is in .gitignore because of production server. How I make media being shared (and editable) so any developer can see any image and assign image to object?
I was thinking about sharing it through git or to store media on production server where Postgres is but not sure how and if it's the best way to do this.
Funny setup...
2 thoughts:
Shared DB sure you have your reasons but why are you running a centralized dev server vs having developers run local and gain access to terminal logs with a DATABASE configuration that points to the remote DB?
You can stash an empty media directory or any other -- description on how at How can I add an empty directory to a Git repository?

Is there a way to share local PostgreSQL between computers?

I recently started working on some project with my friends. I'm working on backend with Django, and others do frontend. As they have no knowledge about Django, I was wondering if I can add the db file into the project folder, so that they can use the local db by just pulling the db file from Github repository.
When I used to use sqlite3, I could do this simply having the sqlite3.db file in my project folder. However, PostgreSQL has me use its program to create database, I'm confused how I can get the db file.
Is it possible to have a local PostgreSQL db file in my Django project so that my friends use the db by just cloning the project and installing PostgreSQL in their computers?
Just so you know, I created my Django project with cookiecutter-django.

Django PostgreSQL setting with separated credential file?

I want to migrate my django's database from MySQL to PostgreSQL.
Previously I've used database configuration options just like this example from Django website.
The MySQL engine on database setting has options: 'read_default_file', so I can separate my database credential on external file.
Now I'm ready to switch to PostgreSQL with psycopg2 engine, but I can't find the similar options like read_default_file.
Is there any solution for this?
Or may be I should change to other database engine of PostgreSQL which has this options? Thanks
read_default_file is purely a mysql thing. It cannot be used for postgresql. The closest equivalent in postgresql is the .pgpass file which is a file that needs to be created in the home directory of the user running the psql client. That defines the user's password.
When you are using django in development creating a file in your your home directory would do the trick. But in production you are not supposed to run the django dev server. Production WSGI servers run under restricted user accounts that may not have a home directory. In that case you need to use the PGPASSFILE environment variable to tell django where to look for the password.

I've installed django on dreamhost using passenger_wsgi now how do I export my development project onto this?

I followed the wiki on http://wiki.dreamhost.com/Django .
Django is installed in my site's directory and I've even created my first project, now what do I do ?
You can copy your project files to the server and transfer your database to the sql server on dreamhost. Don't forget to make changes in your settings.py to reflect the environment. Should work otherwise me thinks.