Skip to content

Commit e7526d6

Browse files
Merge pull request DjangoGirls#1225 from jacebrowning/advance-error-notice
Include a warning icon before blocks that return errors
2 parents db70d19 + c635685 commit e7526d6

File tree

2 files changed

+16
-10
lines changed

2 files changed

+16
-10
lines changed

en/extend_your_application/README.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
{% set warning_icon = '<span class="glyphicon glyphicon-exclamation-sign" style="color: red;" aria-hidden="true" data-toggle="tooltip" title="An error is expected when you run this code!" ></span>' %}
2+
13
# Extend your application
24

35
We've already completed all the different steps necessary for the creation of our website: we know how to write a model, url, view and template. We also know how to make our website pretty.
@@ -30,7 +32,7 @@ We will start with adding a link inside `blog/templates/blog/post_list.html` fil
3032

3133
{% raw %}We want to have a link from a post's title in the post list to the post's detail page. Let's change `<h1><a href="">{{ post.title }}</a></h1>` so that it links to the post's detail page:{% endraw %}
3234

33-
{% filename %}blog/templates/blog/post_list.html{% endfilename %}
35+
{% filename %}{{ warning_icon }} blog/templates/blog/post_list.html{% endfilename %}
3436
```html
3537
<h1><a href="{% url 'post_detail' pk=post.pk %}">{{ post.title }}</a></h1>
3638
```
@@ -53,7 +55,7 @@ We want our first post's detail to be displayed at this **URL**: http://127.0.0.
5355

5456
Let's make a URL in the `blog/urls.py` file to point Django to a *view* named `post_detail`, that will show an entire blog post. Add the line `url(r'^post/(?P<pk>\d+)/$', views.post_detail, name='post_detail'),` to the `blog/urls.py` file. The file should look like this:
5557

56-
{% filename %}blog/urls.py{% endfilename %}
58+
{% filename %}{{ warning_icon }} blog/urls.py{% endfilename %}
5759
```python
5860
from django.conf.urls import url
5961
from . import views
@@ -85,7 +87,7 @@ This time our *view* is given an extra parameter, `pk`. Our *view* needs to catc
8587

8688
Now, we want to get one and only one blog post. To do this, we can use querysets, like this:
8789

88-
{% filename %}blog/views.py{% endfilename %}
90+
{% filename %}{{ warning_icon }} blog/views.py{% endfilename %}
8991
```python
9092
Post.objects.get(pk=pk)
9193
```

en/python_introduction/README.md

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
{% set warning_icon = '<span class="glyphicon glyphicon-exclamation-sign" style="color: red;" aria-hidden="true" data-toggle="tooltip" title="An error is expected when you run this command!" ></span>' %}
2+
13
# Introduction to Python
24

35
> Part of this chapter is based on tutorials by Geek Girls Carrots (https://github.com/ggcarrots/django-carrots).
@@ -134,15 +136,17 @@ These are the basics of every programming language you learn. Ready for somethin
134136

135137
Let's try something new. Can we get the length of a number the same way we could find out the length of our name? Type in `len(304023)` and hit `enter`:
136138

137-
{% filename %}command-line{% endfilename %}
139+
{% filename %}{{ warning_icon }} command-line{% endfilename %}
138140
```python
139141
>>> len(304023)
140142
Traceback (most recent call last):
141143
File "<stdin>", line 1, in <module>
142144
TypeError: object of type 'int' has no len()
143145
```
144146

145-
We got our first error! It says that objects of type "int" (integers, whole numbers) have no length. So what can we do now? Maybe we can write our number as a string? Strings have a length, right?
147+
We got our first error! The {{ warning_icon }} icon is our way of giving you a heads up that the code you are about to run won't work as expected. Making mistakes (even intentional ones) are an important part of learning!
148+
149+
It says that objects of type "int" (integers, whole numbers) have no length. So what can we do now? Maybe we can write our number as a string? Strings have a length, right?
146150

147151
{% filename %}command-line{% endfilename %}
148152
```python
@@ -207,7 +211,7 @@ Awesome, right? Of course, variables can be anything – numbers too! Try this:
207211

208212
But what if we used the wrong name? Can you guess what would happen? Let's try!
209213

210-
{% filename %}command-line{% endfilename %}
214+
{% filename %}{{ warning_icon }} command-line{% endfilename %}
211215
```python
212216
>>> city = "Tokyo"
213217
>>> ctiy
@@ -372,7 +376,7 @@ See, it's similar to a list. But you don't need to remember the index – just t
372376

373377
What happens if we ask Python the value of a key that doesn't exist? Can you guess? Let's try it and see!
374378

375-
{% filename %}command-line{% endfilename %}
379+
{% filename %}{{ warning_icon }} command-line{% endfilename %}
376380
```python
377381
>>> participant['age']
378382
Traceback (most recent call last):
@@ -498,7 +502,7 @@ You can give Python as many numbers to compare as you want, and it will give you
498502

499503
Have you heard of the expression "comparing apples to oranges"? Let's try the Python equivalent:
500504

501-
{% filename %}command-line{% endfilename %}
505+
{% filename %}{{ warning_icon }} command-line{% endfilename %}
502506
```python
503507
>>> 1 > 'django'
504508
Traceback (most recent call last):
@@ -663,7 +667,7 @@ if 3 > 2:
663667

664668
If we were to save and run this, we'd see an error like this:
665669

666-
{% filename %}command-line{% endfilename %}
670+
{% filename %}{{ warning_icon }} command-line{% endfilename %}
667671
```
668672
$ python3 python_intro.py
669673
File "python_intro.py", line 2
@@ -849,7 +853,7 @@ hi()
849853

850854
Remember: The `print` function is indented four spaces within the `if` statement. This is because the function runs when the condition is met. Let's see how it works now:
851855

852-
{% filename %}command-line{% endfilename %}
856+
{% filename %}{{ warning_icon }} command-line{% endfilename %}
853857
```
854858
$ python3 python_intro.py
855859
Traceback (most recent call last):

0 commit comments

Comments
 (0)