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: en/code_editor/instructions.md
+2-2Lines changed: 2 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -26,9 +26,9 @@ Atom is an extremely new code editor created by [GitHub](http://github.com/). It
26
26
27
27
You might be wondering why we are installing this special code editor software, rather than using something like Word or Notepad.
28
28
29
-
The first is that code needs to be **plain text**, and the problem with programs like Word and Textedit is that they don't actually produce plain text, they produce rich text (with fonts and formatting), using custom formats like rtf.
29
+
The first is that code needs to be **plain text**, and the problem with programs like Word and Textedit is that they don't actually produce plain text, they produce rich text (with fonts and formatting), using custom formats like [RTF (Rich Text Format)](https://en.wikipedia.org/wiki/Rich_Text_Format).
30
30
31
-
The second reason is that code editors are specialised in editing code, so they can provide helpful features, like highlighting code with colour according to its meaning, or automatically closing quotes for you.
31
+
The second reason is that code editors are specialised for editing code, so they can provide helpful features like highlighting code with colour according to its meaning, or automatically closing quotes for you.
32
32
33
33
We'll see all this in action later. Soon, you'll come to think of your trusty old code editor as one of your favourite tools :)
Copy file name to clipboardExpand all lines: en/django/README.md
+2-2Lines changed: 2 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,8 +1,8 @@
1
1
# What is Django?
2
2
3
-
Django (_/ˈdʒæŋɡoʊ/ jang-goh_) is a free and open source web application framework, written in Python. It's a web framework - a set of components that helps you to develop websites faster and easier.
3
+
Django (_/ˈdʒæŋɡoʊ/ jang-goh_) is a free and open source web application framework, written in Python. A web framework is a set of components that helps you to develop websites faster and easier.
4
4
5
-
You see, when you're building a website, you always need a similar set of components: a way to handle user authentication (signing up, signing in, signing out), a management panel for your website, forms, a way to upload files, etc.
5
+
When you're building a website, you always need a similar set of components: a way to handle user authentication (signing up, signing in, signing out), a management panel for your website, forms, a way to upload files, etc.
6
6
7
7
Luckily for you other people long ago noticed that web developers face similar problems when building a new site, so they teamed up and created frameworks (Django is one of them) that give you ready-made components you can use.
Copy file name to clipboardExpand all lines: en/django_models/README.md
+12-11Lines changed: 12 additions & 11 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -8,9 +8,9 @@ There is a concept in programming called `Object-oriented programming`. The idea
8
8
9
9
So what is an object? It is a collection of properties and actions. It sounds weird, but we will give you an example.
10
10
11
-
If we want to model a cat we will create an object `Cat` that has some properties, i.e. `color`, `age`, `mood` (i.e. good, bad, sleepy ;)), `owner` (that is a `Person` object or maybe, in case of a stray cat, this property is empty).
11
+
If we want to model a cat we will create an object `Cat` that has some properties such as: `color`, `age`, `mood` (i.e. good, bad, sleepy ;)), and`owner` (that is a `Person` object or maybe, in case of a stray cat, this property is empty).
12
12
13
-
And then the `Cat` has some actions: `purr`, `scratch` or `feed` (in which we will give the cat some `CatFood`, which could be a separate object with properties, i.e. `taste`).
13
+
Then the `Cat` has some actions: `purr`, `scratch`, or `feed` (in which we will give the cat some `CatFood`, which could be a separate object with properties, i.e. `taste`).
14
14
15
15
Cat
16
16
--------
@@ -45,7 +45,7 @@ Well, for sure our blog post needs some text with its content and a title, right
45
45
46
46
What kind of things could be done with a blog post? It would be nice to have some `method` that publishes the post, right?
47
47
48
-
So we will need `publish` method.
48
+
So we will need a `publish` method.
49
49
50
50
Since we already know what we want to achieve, we can start modeling it in Django!
51
51
@@ -131,39 +131,40 @@ All lines starting with `from` or `import` are lines that add some bits from oth
131
131
`class Post(models.Model):` - this line defines our model (it is an `object`).
132
132
133
133
-`class` is a special keyword that indicates that we are defining an object.
134
-
-`Post` is the name of our model, we can give it a different name (but we must avoid special characters and whitespaces). Always start a class name with an uppercase letter.
134
+
-`Post` is the name of our model. We can give it a different name (but we must avoid special characters and whitespaces). Always start a class name with an uppercase letter.
135
135
-`models.Model` means that the Post is a Django Model, so Django knows that it should be saved in the database.
136
136
137
-
Now we define properties we were talking about: `title`, `text`, `created_date`, `published_date` and `author`. To do that we need to define a type of field (is it text? A number? A date? A relation to another object, i.e. a User?).
137
+
Now we define the properties we were talking about: `title`, `text`, `created_date`, `published_date` and `author`. To do that we need to define a type of each field (Is it text? A number? A date? A relation to another object, i.e. a User?).
138
138
139
139
-`models.CharField` - this is how you define text with a limited number of characters.
140
-
-`models.TextField` - this is for long texts without a limit. It will be ideal for a blog post content, right?
140
+
-`models.TextField` - this is for long text without a limit. Sounds ideal for blog post content, right?
141
141
-`models.DateTimeField` - this is a date and time.
142
142
-`models.ForeignKey` - this is a link to another model.
143
143
144
-
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.8/ref/models/fields/#field-types).
144
+
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.8/ref/models/fields/#field-types).
145
145
146
-
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`).
146
+
What about `def publish(self):`? It is exactly our `publish` method we were talking about before. `def` means that this is a function/method and `publish` is the name of the method. You can change the name of the method, if you want. The naming 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`).
147
147
148
148
Methods very often `return` something. There is an example of that in the `__str__` method. In this scenario, when we call `__str__()` we will get a text (**string**) with a Post title.
149
149
150
150
If something is still not clear about models, feel free to ask your coach! We know it is very complicated, especially when you learn what objects and functions are at the same time. But hopefully it looks slightly less magic for you now!
151
151
152
152
### Create tables for models in your database
153
153
154
-
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:
154
+
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:
155
155
156
156
(myvenv) ~/djangogirls$ python manage.py makemigrations blog
157
157
Migrations for 'blog':
158
158
0001_initial.py:
159
159
- Create model Post
160
160
161
-
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:
161
+
Django prepared for us a migration file that we have to apply now to our database. Type`python manage.py migrate blog` and the output should be:
162
162
163
163
(myvenv) ~/djangogirls$ python manage.py migrate blog
164
164
Operations to perform:
165
165
Apply all migrations: blog
166
166
Running migrations:
167
+
Rendering model states... DONE
167
168
Applying blog.0001_initial... OK
168
169
169
-
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!
170
+
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: en/django_start_project/README.md
+17-5Lines changed: 17 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -9,11 +9,11 @@ is copyrighted by Markus Zapke-Gründemann et al.
9
9
10
10
We're going to create a simple blog!
11
11
12
-
The first step towards creating it is to start a new Django project. Basically, this means that we'll run some scripts provided by Django that will create the skeleton of a Django project for us: a bunch of directories and files that we will later use.
12
+
The first step is to start a new Django project. Basically, this means that we'll run some scripts provided by Django that will create the skeleton of a Django project for us: a bunch of directories and files that we will later use.
13
13
14
14
The names of some files and directories are very important for Django. You should not rename the files that we are about to create. Moving them to a different place is also not a good idea. Django needs to maintain a certain structure in order to be able to find important things.
15
15
16
-
> Remember to run everything in the virtualenv. If you don't see a prefix `(myvenv)` in your console you need to activate your virtualenv. We explained how to do that in the __Django installation__ chapter in the __Working with virtualenv__ part. You can do that by typing the following command: `myvenv\Scripts\activate` on Windows or
16
+
> Remember to run everything in the virtualenv. If you don't see a prefix `(myvenv)` in your console you need to activate your virtualenv. We explained how to do that in the __Django installation__ chapter in the __Working with virtualenv__ part. You can do that by typing the following command: `myvenv\Scripts\activate` on Windows or
17
17
`myvenv/bin/activate` on Mac OS / Linux.
18
18
19
19
In your MacOS or Linux console you should run the following command; **don't forget to add the period (or dot) `.` at the end**:
@@ -26,7 +26,7 @@ On Windows; **don't forget to add the period (or dot) `.` at the end**:
26
26
27
27
> The period `.` is crucial because it tells the script to install Django in your current directory (for which the period `.` is a short-hand reference)
28
28
29
-
> **Note** When typing the commands above, remember that you only type the part which starts `django-admin` or `django-admin.py`.
29
+
> **Note** When typing the commands above, remember that you only type the part which starts `django-admin` or `django-admin.py`.
30
30
The`(myvenv) ~/djangogirls$` and `(myvenv) C:\Users\Name\djangogirls>` parts shown here are just examples
31
31
of the prompt that will be inviting your input on your command line.
32
32
@@ -69,7 +69,7 @@ We'll also need to add a path for static files (we'll find out all about static
69
69
70
70
```python
71
71
STATIC_URL='/static/'
72
-
STATIC_ROOT= os.path.join(BASE_DIR, 'static')
72
+
STATIC_ROOT= os.path.join(BASE_DIR, 'static')
73
73
```
74
74
75
75
@@ -92,11 +92,23 @@ To create a database for our blog, let's run the following in the console: `pyth
92
92
93
93
(myvenv) ~/djangogirls$ python manage.py migrate
94
94
Operations to perform:
95
-
Apply all migrations: admin, contenttypes, auth, sessions
Copy file name to clipboardExpand all lines: en/intro_to_command_line/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
@@ -144,7 +144,7 @@ Windows:
144
144
145
145
> mkdir djangogirls
146
146
147
-
This little command will create a folder with the name `djangogirls` on your desktop. You can check if it's there just by looking on your Desktop or by running a `ls`/`dir` command! Try it :)
147
+
This little command will create a folder with the name `djangogirls` on your desktop. You can check if it's there just by looking on your Desktop or by running a `ls` or `dir` command! Try it :)
148
148
149
149
> PRO tip: If you don't want to type the same commands over and over, try pressing the `up arrow` and `down arrow` on your keyboard to cycle through recently used commands.
0 commit comments