13๐
Yes! all of those information are necessary , there is no way you could connect to the database unless those values are
specified.
Yes! user
and password
are the actual credentials of your PostgreSQL database.
regarding deployment, you should set the correct IP/host where your production database is located. that might be example.com or xxx.xxx.xxx.xxx
I think you are concerned about security
(revealing your database credentials in the source) if that is the case you could put your credentials in secure config file like .env and use this library to work with your config file.
2๐
Specifically USER, PASSWORD, HOST, PORT? Is USER and PASSWORD values
that we can create in django settings.py? Or is this the actual
USER/PASSWORD of the database? Also, HOST is currently 127.0.0.1 for
localhost, but when deploying to production, do I change this to the
domain name (http://www.example.com)? And PORT, is it necessary?
The USER
and PASSWORD
is what you configure in the database, then you enter it in the file.
The HOST
is the IP address or hostname where the server is running. In production, you have to check with your hosting provider for the correct details; it is rare that it is your domain name.
The PORT
you only need to adjust if its different than the default port (5432
). If it is different, your host will tell you.
Finally, keep in mind that http://www.example.com
is not a domain name, this the the complete URL. The domain name is example.com
, and the host is www
, the fully qualified hostname is www.example.com
.
- How to hide a field in django modelform?
- Automatic db router for migrations in django
- How to force the use of SSL for some URL of my Django Application?
- How to display a custom error page for HTTP status 405 (method not allowed) in Django when using @require_POST
- How to set default values in TabularInline formset in Django admin
0๐
Yes. See here for Django 2.1 or other versions. You could do the following:
- Login to Heroku
- Go to Resources
- Search for Postgres (Free version/Hobby)
- Then click on the newly generated database link
- Go to settings Under Admin, go to Credentials
Then you can add these variables in your Django production settings, preferably kept secret and called as environment variables () or you can define in the Heroku CLI (using the SET command in Windows). More explanation here.
- How to ensure a Celery task is Preventing overlapping Celery task executions
- How to make trailing slash optional in django
- How to filter search by values that are not available
- Pytest and Django settings runtime changes