Skip to content

Commit 588d213

Browse files
committed
Fix gotbook 2.x build
1 parent f9ccc23 commit 588d213

File tree

24 files changed

+1291
-1048
lines changed

24 files changed

+1291
-1048
lines changed

en/django_forms/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ We need to create a file `post_edit.html` in the `blog/templates/blog` directory
128128
- we have to display the form. We can do that for example with a simple `{{ form.as_p }}`.
129129
- the line above needs to be wrapped with an HTML form tag: `<form method="POST">...</form>`
130130
- we need a `Save` button. We do that with an HTML button: `<button type="submit">Save</button>`
131-
- and finally just after the opening `<form ...>` tag we need to add `{% csrf_token %}`. This is very important, since it makes your forms secure! Django will complain if you forget about this bit if you try to save the form:
131+
- and finally just after the opening `<form ...>` tag we need to add `{% raw %}{% csrf_token %}{% endraw %}`. This is very important, since it makes your forms secure! Django will complain if you forget about this bit if you try to save the form:
132132

133133
![CSFR Forbidden page](images/csrf2.png)
134134

en/django_templates/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ It works! But we want them to be displayed like the static posts we created earl
5454
{% endfor %}
5555
```
5656

57-
Everything you put between `{% for %}` and `{% endfor %}` will be repeated for each object in the list. Refresh your page:
57+
{% raw %}Everything you put between `{% for %}` and `{% endfor %}` will be repeated for each object in the list. Refresh your page:{% endraw %}
5858

5959
![Figure 13.3](images/step3.png)
6060

en/extend_your_application/README.md

Lines changed: 42 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -11,26 +11,30 @@ We already have a `Post` model, so we don't need to add anything to `models.py`.
1111
## Create a link in the template
1212

1313
We will start with adding a link inside `blog/templates/blog/post_list.html` file. So far it should look like:
14+
```html
15+
{% extends 'blog/base.html' %}
1416

15-
{% extends 'blog/base.html' %}
16-
17-
{% block content %}
18-
{% for post in posts %}
19-
<div class="post">
20-
<div class="date">
21-
{{ post.published_date }}
22-
</div>
23-
<h1><a href="">{{ post.title }}</a></h1>
24-
<p>{{ post.text|linebreaks }}</p>
17+
{% block content %}
18+
{% for post in posts %}
19+
<div class="post">
20+
<div class="date">
21+
{{ post.published_date }}
2522
</div>
26-
{% endfor %}
27-
{% endblock content %}
23+
<h1><a href="">{{ post.title }}</a></h1>
24+
<p>{{ post.text|linebreaks }}</p>
25+
</div>
26+
{% endfor %}
27+
{% endblock content %}
2828

29-
We want to have a link to a post detail page on the post's title. Let's change `<h1><a href="">{{ post.title }}</a></h1>` into a link:
29+
```
30+
31+
{% raw %}We want to have a link to a post detail page on the post's title. Let's change `<h1><a href="">{{ post.title }}</a></h1>` into a link:{% endraw %}
3032

31-
<h1><a href="{% url 'blog.views.post_detail' pk=post.pk %}">{{ post.title }}</a></h1>
33+
```html
34+
<h1><a href="{% url 'blog.views.post_detail' pk=post.pk %}">{{ post.title }}</a></h1>
35+
```
3236

33-
Time to explain the mysterious `{% url 'blog.views.post_detail' pk=post.pk %}`. As you might suspect, the `{% %}` notation means that we are using Django template tags. This time we will use one that will create a URL for us!
37+
{% raw %}Time to explain the mysterious `{% url 'blog.views.post_detail' pk=post.pk %}`. As you might suspect, the `{% %}` notation means that we are using Django template tags. This time we will use one that will create a URL for us!{% endraw %}
3438

3539
`blog.views.post_detail` is a path to a `post_detail` *view* we want to create. Please note: `blog` is the name of our application (the directory `blog`), `views` is from the name of the `views.py` file and the last bit - `post_detail` - is the name of the *view*.
3640

@@ -44,13 +48,15 @@ Let's create a URL in `urls.py` for our `post_detail` *view*!
4448

4549
We want to create a URL to point Django to a *view* called `post_detail`, that will show an entire blog post. Add the line `url(r'^post/(?P<pk>[0-9]+)/$', views.post_detail),` to the `blog/urls.py` file. It should look like this:
4650

47-
from django.conf.urls import include, url
48-
from . import views
51+
```python
52+
from django.conf.urls import include, url
53+
from . import views
4954

50-
urlpatterns = [
51-
url(r'^$', views.post_list),
52-
url(r'^post/(?P<pk>[0-9]+)/$', views.post_detail),
53-
]
55+
urlpatterns = [
56+
url(r'^$', views.post_list),
57+
url(r'^post/(?P<pk>[0-9]+)/$', views.post_detail),
58+
]
59+
```
5460

5561
That one looks scary, but no worries - we will explain it for you:
5662
- it starts with `^` again -- "the beginning"
@@ -113,23 +119,25 @@ We will create a file in `blog/templates/blog` called `post_detail.html`.
113119

114120
It will look like this:
115121

116-
{% extends 'blog/base.html' %}
122+
```html
123+
{% extends 'blog/base.html' %}
117124

118-
{% block content %}
119-
<div class="post">
120-
{% if post.published_date %}
121-
<div class="date">
122-
{{ post.published_date }}
123-
</div>
124-
{% endif %}
125-
<h1>{{ post.title }}</h1>
126-
<p>{{ post.text|linebreaks }}</p>
127-
</div>
128-
{% endblock %}
125+
{% block content %}
126+
<div class="post">
127+
{% if post.published_date %}
128+
<div class="date">
129+
{{ post.published_date }}
130+
</div>
131+
{% endif %}
132+
<h1>{{ post.title }}</h1>
133+
<p>{{ post.text|linebreaks }}</p>
134+
</div>
135+
{% endblock %}
136+
```
129137

130138
Once again we are extending `base.html`. In the `content` block we want to display a post's published_date (if it exists), title and text. But we should discuss some important things, right?
131139

132-
`{% if ... %} ... {% endif %}` is a template tag we can use when we want to check something (remember `if ... else ..` from __Introduction to Python__ chapter?). In this scenario we want to check if a post's `published_date` is not empty.
140+
{% raw %}`{% if ... %} ... {% endif %}` is a template tag we can use when we want to check something (remember `if ... else ..` from __Introduction to Python__ chapter?). In this scenario we want to check if a post's `published_date` is not empty.{% endraw %}
133141

134142
Ok, we can refresh our page and see if `Page not found` is gone now.
135143

en/template_extending/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ And now add this line to the beginning of the file:
9797

9898
{% extends 'blog/base.html' %}
9999

100-
It means that we're now extending the `base.html` template in `post_list.html`. Only one thing left: put everything (except the line we just added) between `{% block content %}` and `{% endblock content %}`. Like this:
100+
{% raw %}It means that we're now extending the `base.html` template in `post_list.html`. Only one thing left: put everything (except the line we just added) between `{% block content %}` and `{% endblock content %}`. Like this:{% endraw %}
101101

102102
```html
103103
{% extends 'blog/base.html' %}

0 commit comments

Comments
 (0)