Skip to content

Commit e7ddcc0

Browse files
committed
Editorial tweaks + how to print a given element of a dictionary
1 parent abacdd6 commit e7ddcc0

13 files changed

Lines changed: 73 additions & 64 deletions

File tree

code_editor/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ You're about to write your first line of code, so it's time to download a code e
44

55
There are a lot of different editors and it largely boils down to personal preference. Most Python programmers use complex but extremely powerful IDEs (Integrated Development Environments), such as PyCharm. As a beginner, however - that's probably less suitable; our recommendations are equally powerful, but a lot more simple.
66

7-
Our suggestions are below, but feel free to ask your coach what their preference is - it'll be easier to get help from them.
7+
Our suggestions are below, but feel free to ask your coach what their preferences are - it'll be easier to get help from them.
88

99
## Gedit
1010

@@ -14,7 +14,7 @@ Gedit is an open-source, free editor, available for all operating systems.
1414

1515
## Sublime Text 2
1616

17-
Sublime Text is a very popular editor with a free evaluation period. It's easy to install and use, and available for all operating systems.
17+
Sublime Text is a very popular editor with a free evaluation period. It's easy to install and use, and it's available for all operating systems.
1818

1919
[Download it here](http://www.sublimetext.com/2)
2020

css/README.md

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,9 @@ CSS is a static file, so in order to customize CSS, we need to first configure s
3939

4040
First, we need to create a directory to store our static files in. Go ahead and create a directory called `static` inside your `djangogirls` directory.
4141

42-
static
43-
manage.py
42+
djangogirls
43+
├─── static
44+
└─── manage.py
4445

4546
Open up the `mysite/settings.py` file, scroll to the bottom of it and add the following lines:
4647

@@ -55,8 +56,8 @@ This way Django will know where to find your static files.
5556
Let's create a CSS file now, to add your own style to your web-page. Create a new directory called `css` inside your `static` directory. Then create a new file called `blog.css` inside this `css` directory. Ready?
5657

5758
static
58-
└───css
59-
blog.css
59+
└─── css
60+
blog.css
6061

6162
Time to write some CSS! Open up the `static/css/blog.css` file in your code editor.
6263

@@ -72,7 +73,7 @@ In your `static/css/blog.css` file you should add following code:
7273

7374
`h1 a` is a CSS Selector. Any `a` element inside of an `h1` element (i.e. when we have in code something like: `<h1><a href="">link</a></h1>`) is the tag we're applying our styles to, and we're telling it to change its color to `#FCA205`, which is orange. Of course, you can put your own color here!
7475

75-
In a CSS file we determine styles for elements in the HTML file. The elements are identified by the element name (i.e. `a`, `h1`, `body`), the element class or the element id. Class and id are names you give the element by yourself. Classes define groups of elements, and ids point to specific elements. For example, the following tag may be identified by CSS using the tag name `a`, the class `external_link`, or the id `link_to_wiki_page`:
76+
In a CSS file we determine styles for elements in the HTML file. The elements are identified by the element name (i.e. `a`, `h1`, `body`), the attribute `class` or the attribute `id`. Class and id are names you give the element by yourself. Classes define groups of elements, and ids point to specific elements. For example, the following tag may be identified by CSS using the tag name `a`, the class `external_link`, or the id `link_to_wiki_page`:
7677

7778
<a href="http://en.wikipedia.org/wiki/Django" class="external_link" id="link_to_wiki_page">
7879

@@ -86,7 +87,7 @@ We're just loading static files here :). Then, between the `<head>` and `</head>
8687

8788
<link rel="stylesheet" href="{% static 'css/blog.css' %}">
8889

89-
We just told our template where our CSS file is located. Ok, save the file and refresh the site!
90+
We just told our template where our CSS file is located.
9091

9192
Your file should now look like this:
9293

@@ -114,6 +115,8 @@ Your file should now look like this:
114115
</body>
115116
</html>
116117

118+
OK, save the file and refresh the site!
119+
117120
![Figure 14.2](images/color2.png)
118121

119122
Nice work! Maybe we would also like to give our website a little air and increase the margin on the left side? Let's try this!
@@ -152,7 +155,7 @@ Go ahead and name some parts of the HTML code. Add a class called `page-header`
152155
<h1><a href="/">Django Girls Blog</a></h1>
153156
</div>
154157

155-
And now add a class `post` to your `div` containing blogposts.
158+
And now add a class `post` to your `div` containing a blog post.
156159

157160
<div class="post">
158161
<p>published: {{ post.published_date }}</p>
@@ -210,7 +213,7 @@ We will now add declaration blocks to different selectors. Selectors starting wi
210213
color: #000000;
211214
}
212215

213-
Then surround the HTML code which desplayes the posts with declarations of classes. Replace this:
216+
Then surround the HTML code which displays the posts with declarations of classes. Replace this:
214217

215218
{% for post in posts %}
216219
<div class="post">

django_admin/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ Let's open the `blog/admin.py` file and replace its content with this:
1111

1212
As you can see, we import (include) the Post model defined in the previous chapter. To make our model visible on the admin page, we need to register the model with `admin.site.register(Post)`.
1313

14-
Ok, time to look at our Post model. Remember to run `python manage.py runserver` in the console to run the web server. Go to the browser and type the address:
14+
OK, time to look at our Post model. Remember to run `python manage.py runserver` in the console to run the web server. Go to the browser and type the address:
1515

1616
http://127.0.0.1:8000/admin/
1717

@@ -25,7 +25,7 @@ You should use the username and password you chose when you were creating a data
2525

2626
Go to Posts and experiment a little bit with it. Add five or six blog posts. Don't worry about the content - you can simply copy-paste some text from this tutorial as your posts' content to save time :).
2727

28-
Make sure that at least two or three posts (but not all) have a publish date set. It will be helpful later.
28+
Make sure that at least two or three posts (but not all) have the publish date set. It will be helpful later.
2929

3030
![Django admin](images/edit_post3.png)
3131

django_models/README.md

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -57,24 +57,25 @@ A model in Django is a special kind of object - it is saved in the `database` (d
5757

5858
### Creating an application
5959

60-
To keep everything tidy, we will create a separate application inside our project. It is very nice to have everything organized from the very beginning. To create an application we need to run in the console (from `djangogirls` directory where `manage.py` file is) `python manage.py startapp blog`.
60+
To keep everything tidy, we will create a separate application inside our project. It is very nice to have everything organized from the very beginning. To create an application we need to run the following command in the console (from `djangogirls` directory where `manage.py` file is):
6161

6262
(myvenv) ~/djangogirls$ python manage.py startapp blog
6363

6464
You will notice that a new `blog` directory is created and it contains a number of files now. Our directories and files in our project should look like this:
6565

66-
mysite
67-
├── __init__.py
68-
├── settings.py
69-
├── urls.py
70-
├── wsgi.py
71-
manage.py
72-
blog
73-
├── __init__.py
74-
├── admin.py
75-
├── models.py
76-
├── tests.py
77-
└── views.py
66+
djangogirls
67+
├── mysite
68+
| __init__.py
69+
| settings.py
70+
| urls.py
71+
| wsgi.py
72+
├── manage.py
73+
└── blog
74+
__init__.py
75+
admin.py
76+
models.py
77+
tests.py
78+
views.py
7879

7980
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 `blog` just above `)`. We should also add the `mysite` application (which was created for us when we started a new project in the last chapter). So the final product should look like this:
8081

@@ -91,7 +92,7 @@ After creating an application we also need to tell Django that it should use it.
9192

9293
### Creating a blog post model
9394

94-
In a file `models.py` we define all objects called `Models` - this is a place in which we will define our blog post.
95+
In the `models.py` file we define all objects called `Models` - this is a place in which we will define our blog post.
9596

9697
Let's open `blog/models.py`, remove everything from it and write code like this:
9798

django_orm/README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ We have different pieces in place: the `Post` model is defined in `models.py`, w
44

55
This is exactly what *views* are supposed to do: connect models and templates. In our `post_list` *view* we will need to take models we want to display and pass them to the template. So basically in a *view* we decide what (model) will be displayed in a template.
66

7-
Ok, so how we will achieve it?
7+
OK, so how we will achieve it?
88

99
We need to open our `blog/views.py`. So far `post_list` *view* looks like this:
1010

@@ -13,18 +13,18 @@ We need to open our `blog/views.py`. So far `post_list` *view* looks like this:
1313
def post_list(request):
1414
return render(request, 'blog/post_list.html', {})
1515

16-
Remember when we talked about including code written in different files? Now is a moment when we have to include the model we have written in `models.py`. We will add this line `from .models import Post` like this:
16+
Remember when we talked about including code written in different files? Now it is the moment when we have to include the model we have written in `models.py`. We will add this line `from .models import Post` like this:
1717

1818
from django.shortcuts import render
1919
from .models import Post
2020

2121
Dot after `from` means *current directory* or *current application*. Since `views.py` and `models.py` are in the same directory we can simply use `.` and the name of the file (without `.py`). Then we import the name of the model (`Post`).
2222

23-
But what's next? To take actual blog posts from `Post` model we need something called a `Queryset`.
23+
But what's next? To take actual blog posts from `Post` model we need something called `Queryset`.
2424

2525
## Queryset
2626

27-
So now we are interested in a list of blog posts, right? But all we have is model `Post`. A Queryset will give us a collection we are looking for. All we need to do is use:
27+
So now we are interested in a list of blog posts, right? But all we have is the `Post` model. A Queryset will give us a collection we are looking for. All we need to do is use:
2828

2929
Post.objects.all()
3030

@@ -52,7 +52,7 @@ Now we put this piece of code inside the `post_list` file, by adding it to the f
5252
return render(request, 'blog/post_list.html', {})
5353

5454
Please note that we create a *variable* for our queryset: `posts`. Treat this as the name of our queryset. From now on we can refer to it by this name.
55-
The last missing part is to pass the `posts` queryset to the template (we will cover how to display it in a next chapter).
55+
The last missing part is passing the `posts` queryset to the template (we will cover how to display it in a next chapter).
5656

5757
In the `render` function we already have parameter with `request` (so everything we receive from the user via the Internet) and a template file `'blog/post_list.html'`. The last parameter, which looks like this: `{}` is a place in which we can add some things for the template to use. We need to give them names (we will stick to `'posts'` right now :)). It should look like this: `{'posts': posts}`. Please note that the part before `:` is wrapped with quotes `''`.
5858

django_start_project/README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@ The first step towards creating it is starting a new Django project. Basically,
1313

1414
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.
1515

16-
In console you should run (remember that you don't type `(myvenv) ~/djangogirls$`, ok?):
16+
In console you should run (remember that you don't type `(myvenv) ~/djangogirls$`, OK?):
1717

18-
> 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 that in __Django installation__ chapter in __Working with virtualenv__ part.
18+
> 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.
1919
2020
Run on Windows:
2121

@@ -27,8 +27,8 @@ or on Linux or Mac OS:
2727

2828
`django-admin.py` is a script that will create the directories and files for you. You should now have a directory structure which looks like this:
2929

30-
manage.py
31-
30+
djangogirls
31+
├───manage.py
3232
└───mysite
3333
settings.py
3434
urls.py
@@ -48,7 +48,7 @@ Let's ignore the other files for now - we won't change them. The only thing to r
4848

4949
Let's make some changes in `mysite/settings.py`. Open the file using the code editor you installed earlier.
5050

51-
It would be nice to have the correct time on our website. Go to http://en.wikipedia.org/wiki/List_of_tz_database_time_zones and copy your relevant time zone (TZ). (eg. `Europe/Berlin` )
51+
It would be nice to have the correct time on our website. Go to http://en.wikipedia.org/wiki/List_of_tz_database_time_zones and copy your relevant time zone (TZ). (eg. `Europe/Berlin` )
5252

5353
You should find lines that contain `USE_TZ` and `TIME_ZONE` and modify them to look like this, substituting `Europe/Berlin` with your relevant time zone:
5454

django_templates/README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ __Django template tags__ allow us to transfer Python-like things into HTML, so y
1010

1111
## Display post list template
1212

13-
In the previous chapter we gave our template a list of posts in a `posts` variable. Now we will display it in HTML.
13+
In the previous chapter we gave our template a list of posts in the `posts` variable. Now we will display it in HTML.
1414

1515
To print a variable in Django template, we use double curly brackets with the variable's name inside, like this:
1616

@@ -24,7 +24,7 @@ As you can see, all we've got is this:
2424

2525
[<Post: My second post>, <Post: My first post>]
2626

27-
This means that Django understand it as a list of objects. Remember from __Introduction to Python__ how we can display lists? Yes, with for loops! In a Django template, you do them this way:
27+
This means that Django understand it as a list of objects. Remember from __Introduction to Python__ how we can display lists? Yes, with the for loops! In a Django template, you do them this way:
2828

2929
{% for post in posts %}
3030
{{ post }}
@@ -34,7 +34,7 @@ Try this in your template.
3434

3535
![Figure 13.2](images/step2.png)
3636

37-
It works! But we want them to be displayed in a way we created earlier in the __Introduction to HTML__ chapter - like the static posts we put there before. You can mix HTML and template tags. Our `body` will look like this:
37+
It works! But we want them to be displayed like the static posts we created earlier in the __Introduction to HTML__ chapter. You can mix HTML and template tags. Our `body` will look like this:
3838

3939
<div>
4040
<h1><a href="/">Django Girls Blog</a></h1>

django_urls/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,11 @@ As you can see, Django already put something here for us.
3131

3232
Lines that start with `#` are comments - it means that those lines won't be executed by Python. Pretty handy, right?
3333

34-
The admin url, which you visited in previous chapter is already here:
34+
The admin URL, which you visited in previous chapter is already here:
3535

3636
url(r'^admin/', include(admin.site.urls)),
3737

38-
It means that for every url that starts with `admin/` Django will find a corresponding *view*. In this case we're including a lot of admin urls so it isn't all packed into this small file -- it's more readable and cleaner.
38+
It means that for every URL that starts with `admin/` Django will find a corresponding *view*. In this case we're including a lot of admin URLs so it isn't all packed into this small file -- it's more readable and cleaner.
3939

4040
## Regex
4141

how_internet_works/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# How the Internet works
22

3-
*This chapter is inspired by a talk "How the Internet works" by Jessica McKellar (http://web.mit.edu/jesstess/www/).*
3+
> This chapter is inspired by a talk "How the Internet works" by Jessica McKellar (http://web.mit.edu/jesstess/www/).
44
55
We bet you use the Internet every day. But do you actually know what happens when you type an address like http://djangogirls.org into your browser and press 'Enter'?
66

@@ -13,7 +13,7 @@ follow its instructions and present all these files that your website is made of
1313
As with every file, we need to store HTML files somewhere on a hard disk. For the Internet, we use special, powerful computers called *servers*. They don't have
1414
a screen, mouse or a keyboard, because their main purpose is to store data and serve it. That's why they're called *servers* -- because they *serve* you data.
1515

16-
Ok, but you want to know how the Internet looks like, right?
16+
OK, but you want to know how the Internet looks like, right?
1717

1818
We drew you a picture! It looks like this:
1919

0 commit comments

Comments
 (0)