Reputation: 789
EDIT - New, similar question -: django.db.backends.postgresql_psycopg2, for 'NAME', I put the database name, for 'USER' and 'PASSWORD' I put the username and password I created.. and then what do I put for host and port? host I put 127.0.0.1? And port I put 5432? This was the host and port I received when installing PostgreSQL. Also, when I installed PostgreSQL, it asked me to create a password for the database, when do I use that password?
Original question which has now been answered: I'm new to databases and django, I was reading the djangobook (http://www.djangobook.com/en/2.0/chapter05.html) and I installed PostgreSQL.
In the djangobook, it says "We’ll assume you’ve set up a database server, activated it, and created a database within it (e.g., using a CREATE DATABASE statement)"
What I did was installed PostgreSQL and psycopg2-2.5.1 and then created a user and database using these instructions: https://confluence.atlassian.com/display/CONF30/Database+Setup+for+PostgreSQL+on+Windows
However, I stopped when I reached the "Setting up Confluence to use the PostgreSQL Database". Do I need to do the "Setting up Confluence to use the PostgreSQL Database" in order to use by database while building an app using django?
Upvotes: 1
Views: 4263
Reputation: 128993
No, you'll only need the first section, and only a part of it at that.
PostgreSQL is a database engine that can service many applications. Confluence is one of these applications. You were following a guide to install Confluence, which happened to also include a section on installing PostgreSQL. If you only followed the PostgreSQL installation part, you should be fine.
If you followed the whole first section, though, then one thing you might want to change is the user. confuser
indicates that the user is being used for Confluence, which isn't really the case if you're not using it for Confluence. django
might be a more appropriate user name.
Once you've got PostgreSQL and psycopg installed and a django
user set up, it's a fairly simple matter to tell Django how to connect. As you discovered, you'll want to set
django.db.backends.postgresql_psycopg2
,127.0.0.1
, which always means “this computer”, andYou also asked about the difference between the password you gave the PostgreSQL installer and the user you created for Django. In short, you want to create users for each of your applications, so if for some reason the credentials are compromised and someone can connect with them, they're restricted to that application's database. The postgres
user with the password you gave the installer should not be given to applications, but is for administration: creating new users and databases, for example.
Upvotes: 3