Skip to content

Commit e19b9f8

Browse files
committed
Cleanup with folders created by gitbook.
Chapter about postgres - resolves DjangoGirls#7
1 parent e40d778 commit e19b9f8

File tree

20 files changed

+100
-12
lines changed

20 files changed

+100
-12
lines changed

SUMMARY.md

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,23 @@
11
# Summary
22

3-
* [How the Internet works?](how_the_internet_works/README.md)
4-
* [Python installation](install_python/README.md)
5-
* [Introduction to Python](try_python/README.md)
6-
* [What is Django?](django_-_why_you_need_a_webframework/README.md)
3+
* [How the Internet works?](how_internet_works/README.md)
4+
* [Python installation](python_installation/README.md)
5+
* [Introduction to Python](python_introduction/README.md)
6+
* [What is Django?](django/README.md)
7+
* [Database](database/README.md)
78
* [Django installation](django_installation/README.md)
8-
* [Starting Django project](starting_django_project/README.md)
9+
* [Starting Django project](django_start_project/README.md)
910
* [Django models](django_models/README.md)
1011
* [Django admin](django_admin/README.md)
1112
* [Django urls](django_urls/README.md)
12-
* [Django views - time to create!](django_views_-_time_to_create/README.md)
13+
* [Django views - time to create!](django_views/README.md)
1314
* [Introduction to HTML](html/README.md)
14-
* [Django ORM (Querysets)](django_orm_querysets/README.md)
15+
* [Django ORM (Querysets)](django_orm/README.md)
1516
* [Django templates](django_templates/README.md)
1617
* [CSS - make it pretty](css/README.md)
1718
* [Template extending](template_extending/README.md)
1819
* [Extend your application](extend_your_application/README.md)
1920
* [Deploy!](deploy/README.md)
2021
* [Django Forms](django_forms/README.md)
2122
* [Domain](domain/README.md)
22-
* [Homework: add more to your website!](homework_add_more_to_your_website/README.md)
23-
23+
* [Homework: add more to your website!](homework/README.md)

database/README.md

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
# Database
2+
3+
Most of web application 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..
4+
5+
We will be using a PostgreSQL database to store our data. It would be easier to just use a default Django database called sqlite, but it's not good for a production use. If you want to have your application available in the Internet, not only your computer, you will need PostgreSQL.
6+
7+
# PostgreSQL installation
8+
9+
## Windows
10+
11+
PostgreSQL is recommending to install it using a program you can find here: http://www.enterprisedb.com/products-services-training/pgdownload#windows
12+
13+
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/
14+
15+
## Mac OS X
16+
17+
The easiest way is to download a free [Postgres.app](http://postgresapp.com/) and install it like any other application on your operating system.
18+
19+
Go ahead, download it, drag to the Applications folder and run by double clicking. That's it!
20+
21+
## Linux
22+
23+
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](https://wiki.postgresql.org/wiki/Detailed_installation_guides#General_Linux).
24+
25+
### Ubuntu
26+
27+
Go to your console and run following command:
28+
29+
sudo apt-get install postgresql postgresql-contrib
30+
31+
### Fedora
32+
33+
sudo yum install postgresql93-server
34+
35+
# Create database
36+
37+
Now we need to create our database user and our first database!
38+
39+
First, let's make our console into postgres mode:
40+
41+
$ psql
42+
psql (9.3.4)
43+
Type "help" for help.
44+
#
45+
46+
Our `$` now changed into `#`, it means that we're now giving commands to PostgreSQL. Let's create a user:
47+
48+
# CREATE USER name;
49+
CREATE ROLE
50+
51+
Of course, replace `name` with your own name. Now it's time for a database for your Django project:
52+
53+
# CREATE DATABASE djangogirls OWNER name;
54+
CREATE DATABASE
55+
56+
Awesome! All ready.
57+
58+

django_-_why_you_need_a_webframework/README.md renamed to django/README.md

File renamed without changes.

django_installation/README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,14 @@ Now, when you have your `virtualenv` started, you can install Django using PIP.
5656
Successfully installed django
5757
Cleaning up...
5858

59+
### Installing PostgreSQL package for Python
60+
61+
(blog) ~$ pip install psycopg2
62+
Downloading/unpacking psycopg2
63+
Installing collected packages: psycopg2
64+
Successfully installed psycopg2
65+
Cleaning up...
66+
5967
That's it! Now you are finally ready to create a Django application.
6068

6169

File renamed without changes.
Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,11 +41,33 @@ It would be nice to have a correct time on our website. You should find lines th
4141
USE_TZ = False
4242
TIME_ZONE = 'Europe/Berlin'
4343

44-
## Creating a database
44+
## Setup a database
4545

46-
Most of web application 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..
46+
There is a number of different database systems that store data for you. We will use one of the best ones: `PostgreSQL`, which we installed in __Database__ chapter.
4747

48-
There is a number of different database systems that store data for you. We will use one of the simpliest: `sqlite3`, which was installed with Django. But if you plan to do some serious websites in the future we recommend looking at `PostgreSQL`.
48+
Find this part in your `mysite/settings.py` file:
49+
50+
DATABASES = {
51+
'default': {
52+
'ENGINE': 'django.db.backends.sqlite3',
53+
'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
54+
}
55+
}
56+
57+
And replace it with this:
58+
59+
DATABASES = {
60+
'default': {
61+
'ENGINE': 'django.db.backends.postgresql_psycopg2',
62+
'NAME': 'djangogirls',
63+
'USER': 'yourname',
64+
'PASSWORD': '',
65+
'HOST': 'localhost',
66+
'PORT': '',
67+
}
68+
}
69+
70+
Make sure to replace `yourname` with a user name you created in __Database__ section. Then save a file.
4971

5072
To create a database for our blog we will type in console/command-line `python manage.py syncdb`. It should look like this:
5173

File renamed without changes.
File renamed without changes.
File renamed without changes.

homework_add_more_to_your_website/README.md renamed to homework/README.md

File renamed without changes.

0 commit comments

Comments
 (0)