In Uncategorized
  1. Create Database
  2. Configure in 
  3. Run migrations

In this tutorial we will start with a blank django project and create a new postgress databse. This process is very simple

Create Database

First lets create our NEW postgress database. We will call our database “pgadminstudy”.

Configure Database

No lets configure in of our django project. In we will need to update our DATABASE to reflect our connection to posgress instead of the default sqlite.

Default Django DATABASE

We will update “Engine”  and “Name” to reflece our postgress engine name “django.db.backends.postgresql” and the name shoud be the name we gave our database, in our case “pgadminstudy”

Then we will need to add a “USER“, “PASSWORD”, “HOST” and “PORT“. 

IF you are working with a local postgress database your “USERNAME” will be “postgres” 

“PASSWORD” is the password you created for your local pgadmin account.

“HOST” is simply “localhost” and “PORT” is “5432”

This information can be found when you open up pgadmin then right click on your server and select properties. All this info should be under the “Connection” Tab.

Here is hat DATABASE should look like now in 

Migrate Database

No before we run a migration i created a simple model that i want to be added to our databse. 

No in our command prompt we can run “python makemigrations” and “python migrate”

No when we go into pgadmin and select our server –> database we can go to “schemas” –> “Public” — “Tables” and see our new table. Thats it! You django app should run just like it did with sqllite.

Contact Us

We're not around right now. But you can send us an email and we'll get back to you, asap.