diff --git a/en/css/README.md b/en/css/README.md index a5abd124e8c..d9a612f16ff 100644 --- a/en/css/README.md +++ b/en/css/README.md @@ -39,43 +39,41 @@ Finally we will take a closer look at these things we've been calling __static f Django already knows where to find the static files for the built-in "admin" app. Now we need to add some static files for our own app, `blog`. -We do that by creating a folder called `static` inside the blog app: +We do that by creating a folder called `static` inside the blog app.However, to avoid naming conflicts between different apps, Django recommends creating another folder with your app name inside the static folder: ``` djangogirls ├── blog │ ├── migrations │ ├── static -│ └── templates +│ │ └── blog +│ └── templates └── mysite ``` -Django will automatically find any folders called "static" inside any of your apps' folders. Then it will be able to use their contents as static files. - +Django will automatically find any folders called "static" inside any of your apps' folders. Then it will be able to use their contents as static files.The additional app-name folder (blog) helps Django distinguish between static files from different apps when you have multiple apps in your project ## Your first CSS file! -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? +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/blog` directory. Then create a new file called `blog.css` inside this `css` directory. Ready? ``` djangogirls └─── blog └─── static - └─── css - └─── blog.css + └─── blog + └─── css + └─── blog.css ``` -Time to write some CSS! Open up the `blog/static/css/blog.css` file in your code editor. +Time to write some CSS! Open up the `blog/static/blog/css/blog.css` file in your code editor. We won't be going too deep into customizing and learning about CSS here. There is a recommendation for a free CSS course at the end of this page if you would like to learn more. But let's do at least a little. Maybe we could change the color of our headers? To understand colors, computers use special codes. These codes start with `#` followed by 6 letters (A–F) and numbers (0–9). For example, the code for blue is `#0000FF`. You can find the color codes for many colors here: https://www.colorpicker.com/. You may also use predefined [named colors](https://developer.mozilla.org/en-US/docs/Web/CSS/named-color), such as `red` and `green`. - - -In your `blog/static/css/blog.css` file you should add the following code: - -{% filename %}blog/static/css/blog.css{% endfilename %} +In your `blog/static/blog/css/blog.css` file you should add the following code: +{% filename %}blog/static/blog/css/blog.css{% endfilename %} ```css h1 a, h2 a { color: #C25100; @@ -105,8 +103,11 @@ Between the `
` and `` tags, after the links to the Bootstrap CSS fi {% filename %}blog/templates/blog/post_list.html{% endfilename %} ```html - + ``` + +Note that we reference the CSS file as `blog/css/blog.css` because our CSS file is now located in the `blog/static/blog/css/blog.css` path. The `{% static %}` template tag automatically handles the `static/` part of the path. + The browser reads the files in the order they're given, so we need to make sure this is in the right place. Otherwise the code in our file may be overridden by code in Bootstrap files. We just told our template where our CSS file is located. @@ -120,7 +121,7 @@ Your file should now look like this: