Most of web applications have their own database. A database is a collection of data. This is a place in which you will store all information about users, all your blog post texts, etc..
We will be using a PostgreSQL database to store our data. It would be easier to use a default Django database called sqlite, but it's not good for production use (by production we mean: real, running websites). If you want to have your application available in the Internet, not only on your computer, you will need PostgreSQL.
PostgreSQL is recommending to install it using a program you can find here: http://www.enterprisedb.com/products-services-training/pgdownload#windows
Choose a newest version available for your operating system. Download this Installer, run it and then follow the instructions available here: http://www.postgresqltutorial.com/install-postgresql/. Take note of the installation directory, you will need it in the next step (most likely it will be C:\Program Files\PostgreSQL\9.3).
The easiest way is to download a free Postgres.app and install it like any other application on your operating system.
Go ahead, download it, drag to the Applications folder and run by double clicking. That's it!
Of course, installation depends on Linux distribution. We've added most popular ones, but if you can't find yours, here are all the tutorials.
Go to your console and run a following command:
sudo apt-get install postgresql postgresql-contrib
sudo yum install postgresql93-server
Now we need to create our database user and our first database. You can add many databases in PostgreSQL, so if you have more than one website, you should have a separate database for each one!
If you're using Windows, there is a little bit more we need to do. For now you don't need to understand these steps, but feel free to ask your coach if you're curious!
- Open the Command Prompt (Start menu → All Programs → Accessories → Command Prompt)
- Type the following
setx PATH "%PATH%;C:\Program Files\PostgreSQL\9.3\bin"(you can also paste things into the Command Prompt by right clicking and selectingPaste). Make sure that the path is the same as you noted during installation with\binadded at the end. You should see the messageSUCCESS: Specified value was saved.. - Close the Command Prompt and it open again.
First, let's make our console into postgres mode by typing psql. Remember the part about console?
On Mac OS X you can do this by launching the
Terminalapplication (it's in Applications → Utilities). On Linux, it's probably under Applications → Accessories → Terminal. On Windows you need to go to Start menu → All Programs → Accessories → Command Prompt. Further, on Windows,psqlmight require logging in using the username and password you chose during installation. Ifpsqlis asking you for password and doesn't seem to work, trypsql -U <username> -Wfirst and enter the password later.
$ psql
psql (9.3.4)
Type "help" for help.
#
Our $ now changed into #, it means that we're now giving commands to PostgreSQL. Let's create a user:
# CREATE USER name;
CREATE ROLE
Of course, replace name with your own name. Remember that you should not use diacritic letters and whitespaces, i.e. bożena maria is invalid! You need to transform it into bozena_maria.
Now it's time to create a database for your Django project:
# CREATE DATABASE djangogirls OWNER name;
CREATE DATABASE
Remember to replace name with the name you've chosen (i.e. bozena_maria).
Awesome! All ready!