You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: django_admin/README.md
+11-2Lines changed: 11 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -19,7 +19,16 @@ You will see a login page like this:
19
19
20
20

21
21
22
-
You should use the username and password you chose when you were creating a database (in the __Starting Django project__ chapter). After logging in, you should see the Django admin dashboard.
22
+
In order to log in you need to create a *superuser* - a user which has control over everything on the site. Go back to you command-line and type `python manage.py createsuperuser`, press enter and type your username (lowercase, no spaces), email address and password when you're asked for them. The output should look like this (where username and email should be your own ones):
Copy file name to clipboardExpand all lines: django_installation/README.md
+3-3Lines changed: 3 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -88,10 +88,10 @@ OK, we have all important dependencies in place. We can finally install Django!
88
88
89
89
## Installing Django
90
90
91
-
Now that you have your `virtualenv` started, you can install Django using `pip`. In the console, run `pip install django==1.6.6` (note that we use a double equal sign: `==`).
91
+
Now that you have your `virtualenv` started, you can install Django using `pip`. In the console, run `pip install django==1.7` (note that we use a double equal sign: `==`).
Copy file name to clipboardExpand all lines: django_models/README.md
+22-14Lines changed: 22 additions & 14 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -73,11 +73,13 @@ You will notice that a new `blog` directory is created and it contains a number
73
73
| wsgi.py
74
74
├── manage.py
75
75
└── blog
76
-
__init__.py
77
-
admin.py
78
-
models.py
79
-
tests.py
80
-
views.py
76
+
├── migrations
77
+
| __init__.py
78
+
├── __init__.py
79
+
├── admin.py
80
+
├── models.py
81
+
├── tests.py
82
+
└── views.py
81
83
82
84
After creating an application we also need to tell Django that it should use it. We do that in the file `mysite/settings.py`. We need to find `INSTALLED_APPS` and add a line containing `'blog',` just above `)`. So the final product should look like this:
83
85
@@ -134,7 +136,7 @@ Now we define properties we were talking about: `title`, `text`, `created_date`,
134
136
-`models.DateTimeField` - this is a date and time.
135
137
-`models.ForeignKey` - this is a link to another model.
136
138
137
-
We will not explain every bit of code here, since it would take too much time. You should take a look at Django's documentation, if you want to know more about Model fields and how to define things other than those described above (https://docs.djangoproject.com/en/1.6/ref/models/fields/#field-types).
139
+
We will not explain every bit of code here, since it would take too much time. You should take a look at Django's documentation, if you want to know more about Model fields and how to define things other than those described above (https://docs.djangoproject.com/en/1.7/ref/models/fields/#field-types).
138
140
139
141
What about `def publish(self):`? It is exactly our `publish` method we were talking about before. `def` means that this is a function/method. `publish` is the name of the method. You can change it, if you want. The rule is that we use lowercase and underscores instead of whitespaces (i.e. if you want to have a method that calculates average price you could call it `calculate_average_price`).
140
142
@@ -144,13 +146,19 @@ If something is still not clear about models, feel free to ask your coach! We kn
144
146
145
147
### Create tables for models in your database
146
148
147
-
The last step here is to add our new model to our database. It is as easy as typing `python manage.py syncdb`. It will look like this:
149
+
The last step here is to add our new model to our database. First we have to make Django know that we have some changes in our model (we have just created it), type `python manage.py makemigrations blog`. It will look like this:
148
150
149
-
(myvenv) ~/djangogirls$ python manage.py syncdb
150
-
Creating tables ...
151
-
Creating table blog_post
152
-
Installing custom SQL ...
153
-
Installing indexes ...
154
-
Installed 0 object(s) from 0 fixture(s)
151
+
(myvenv) ~/djangogirls$ python manage.py makemigrations blog
152
+
Migrations for 'blog':
153
+
0001_initial.py:
154
+
- Create model Post
155
155
156
-
It would be nice to see this Post model, right? Jump to the next chapter to see what your Post looks like!
156
+
Django prepared for us a migration file that we have to apply now to our database, type `python manage.py migrate blog`, the output should be:
157
+
158
+
(myvenv) ~/djangogirls$ python manage.py migrate blog
159
+
Operations to perform:
160
+
Apply all migrations: blog
161
+
Running migrations:
162
+
Applying blog.0001_initial... OK
163
+
164
+
Hurray! Our Post model is now in our database, it would be nice to see it, right? Jump to the next chapter to see what your Post looks like!
Copy file name to clipboardExpand all lines: django_start_project/README.md
+10-26Lines changed: 10 additions & 26 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -68,32 +68,16 @@ This is already set up in this part of your `mysite/settings.py` file:
68
68
}
69
69
}
70
70
71
-
To create a database for our blog, let's run the following in the console: `python manage.py syncdb` (we need to be the `djangogirls` directory that contains the `manage.py` file). If that goes well, you should see something like this:
72
-
73
-
(myvenv) ~/djangogirls$ python manage.py syncdb
74
-
Creating tables ...
75
-
Creating table django_admin_log
76
-
Creating table auth_permission
77
-
Creating table auth_group_permissions
78
-
Creating table auth_group
79
-
Creating table auth_user_groups
80
-
Creating table auth_user_user_permissions
81
-
Creating table auth_user
82
-
Creating table django_content_type
83
-
Creating table django_session
84
-
85
-
You just installed Django's auth system, which means you don't have any superusers defined.
It will ask you if you want to create a *superuser* - a user which has control over everything on the site. Type `yes`, press enter and type your username (lowercase, no spaces), email address and password when you're asked for them. Remember this username and password! We'll use it later.
71
+
To create a database for our blog, let's run the following in the console: `python manage.py migrate` (we need to be in the `djangogirls` directory that contains the `manage.py` file). If that goes well, you should see something like this:
72
+
73
+
(myvenv) ~/djangogirls$ python manage.py migrate
74
+
Operations to perform:
75
+
Apply all migrations: admin, contenttypes, auth, sessions
76
+
Running migrations:
77
+
Applying contenttypes.0001_initial... OK
78
+
Applying auth.0001_initial... OK
79
+
Applying admin.0001_initial... OK
80
+
Applying sessions.0001_initial... OK
97
81
98
82
And we're done! Time to start the web server and see if our website is working!
Copy file name to clipboardExpand all lines: django_urls/README.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -92,5 +92,5 @@ There is no "It works" anymore, huh? Don't worry, it's just an error page, nothi
92
92
93
93
You can read that there is __no attribute 'post_list'__. Is *post_list* reminding you of anything? This is how we called our view! This means that everything is in place, we just didn't create our *view* yet. No worries, we will get there.
94
94
95
-
> If you want to know more about Django URLconfs, look at the official documentation: https://docs.djangoproject.com/en/1.6/topics/http/urls/
95
+
> If you want to know more about Django URLconfs, look at the official documentation: https://docs.djangoproject.com/en/1.7/topics/http/urls/
Copy file name to clipboardExpand all lines: whats_next/README.md
+2-3Lines changed: 2 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -15,13 +15,12 @@ After that make sure to:
15
15
16
16
Yes! First, go ahead and try our other book, called [Django Girls Tutorial: Extensions](http://djangogirls.gitbooks.io/django-girls-tutorial-extensions/).
17
17
18
-
Later on, you can try recources listed below. They're all highly recommended!
19
-
-[Django's official tutorial](https://docs.djangoproject.com/en/1.6/intro/tutorial01/)
18
+
Later on, you can try recources listed below. They're all very recommended!
19
+
-[Django's official tutorial](https://docs.djangoproject.com/en/1.7/intro/tutorial01/)
0 commit comments