Skip to content

Commit 3bbef2a

Browse files
committed
🐍🌏 Switched to PythonAnywhere for the deploy chapter.
Thanks to Harry Percival for the huge amount of work and to all the contributors who helped review this chapter. A copy of the full commit history of this can be found on the posterity/python-anywhere-rewrite.
1 parent fb2d448 commit 3bbef2a

File tree

14 files changed

+346
-214
lines changed

14 files changed

+346
-214
lines changed

en/code_editor/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,5 +34,5 @@ The first is that code needs to be **plain text**, and the problem with programs
3434

3535
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.
3636

37-
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 :)
37+
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 :)
3838

en/css/README.md

Lines changed: 19 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -33,53 +33,50 @@ Looking nicer already!
3333

3434
## Static files in Django
3535

36-
Another thing you will learn about today is called __static files__. Static files are all your CSS and images -- files that are not dynamic, so their content doesn't depend on request context and will be the same for every user.
36+
Finally we will take a closer look at these things we've been calling __static files__. Static files are all your CSS and images -- files that are not dynamic, so their content doesn't depend on the request context and will be the same for every user.
3737

38-
CSS is a static file, so in order to customize CSS, we need to first configure static files in Django. You'll only need to do it once. Let's start:
3938

39+
### Where to put static files for Django
4040

41-
### Configure static files in Django
41+
As you saw when we ran `collectstatic` on the server, Django already knows where to find the static files for the built-in "admin" app. Now we just need to add some static files for our own app, `blog`.
4242

43-
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.
43+
We do that by creating a folder called `static` inside the blog app:
4444

4545
djangogirls
46-
├─── static
47-
└─── manage.py
46+
├── blog
47+
│ ├── migrations
48+
│ └── static
49+
└── mysite
4850

49-
Open up the `mysite/settings.py` file, scroll to the bottom of it and add the following lines:
51+
Django will automatically find any folders called "static" inside any of your apps' folders, and it will be able to use their contents as static files.
5052

51-
```python
52-
STATICFILES_DIRS = (
53-
os.path.join(BASE_DIR, "static"),
54-
)
55-
```
56-
57-
This way Django will know where to find your static files.
5853

5954

6055
## Your first CSS file!
6156

6257
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?
6358

64-
static
65-
└─── css
66-
blog.css
59+
djangogirls
60+
└─── blog
61+
└─── static
62+
└─── css
63+
└─── blog.css
6764

68-
Time to write some CSS! Open up the `static/css/blog.css` file in your code editor.
65+
Time to write some CSS! Open up the `blog/static/css/blog.css` file in your code editor.
6966

7067
We won't be going too deep into customizing and learning about CSS here, because it's pretty easy and you can learn it on your own after this workshop. We really recommend doing this [Codeacademy HTML & CSS course](http://www.codecademy.com/tracks/web) to learn everything you need to know about making your websites more pretty with CSS.
7168

7269
But let's do at least a little. Maybe we could change the color of our header? To understand colors, computers use special codes. They start with `#` and are followed by 6 letters (A-F) and numbers (0-9). You can find color codes for example here: http://www.colorpicker.com/. You may also use [predefined colors](http://www.w3schools.com/cssref/css_colornames.asp), such as `red` and `green`.
7370

74-
In your `static/css/blog.css` file you should add the following code:
71+
In your `blog/static/css/blog.css` file you should add the following code:
7572

7673
```css
7774
h1 a {
7875
color: #FCA205;
7976
}
8077
```
8178

82-
`h1 a` is a CSS Selector. This means we're applying our styles to any `a` element inside of an `h1` element (e.g. when we have in code something like: `<h1><a href="">link</a></h1>`). In this case, we're telling it to change its color to `#FCA205`, which is orange. Of course, you can put your own color here!
79+
`h1 a` is a CSS Selector. This means we're applying our styles to any `a` element inside of an `h1` element (e.g. when we have in code something like: `<h1><a href="">link</a></h1>`). In this case, we're telling it to change its color to `#FCA205`, which is orange. Of course, you can put your own color here!
8380

8481
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`:
8582

@@ -154,7 +151,7 @@ Maybe we can customize the font in our header? Paste this into your `<head>` in
154151

155152
This line will import a font called *Lobster* from Google Fonts (https://www.google.com/fonts).
156153

157-
Now add the line `font-family: 'Lobster';` in the CSS file `static/css/blog.css` inside the `h1 a` declaration block (the code between the braces `{` and `}`) and refresh the page:
154+
Now add the line `font-family: 'Lobster';` in the CSS file `blog/static/css/blog.css` inside the `h1 a` declaration block (the code between the braces `{` and `}`) and refresh the page:
158155

159156
```css
160157
h1 a {
@@ -188,7 +185,7 @@ And now add a class `post` to your `div` containing a blog post.
188185
</div>
189186
```
190187

191-
We will now add declaration blocks to different selectors. Selectors starting with `.` relate to classes. There are many great tutorials and explanations about CSS on the Web to help you understand the following code. For now, just copy and paste it into your `djangogirls/static/css/blog.css` file:
188+
We will now add declaration blocks to different selectors. Selectors starting with `.` relate to classes. There are many great tutorials and explanations about CSS on the Web to help you understand the following code. For now, just copy and paste it into your `blog/static/css/blog.css` file:
192189

193190
```css
194191
.page-header {

0 commit comments

Comments
 (0)