You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
<a href="{% url 'login' %}" class="top-menu">{% include './icons/lock-fill.svg' %}</a>
100
100
```
101
101
102
102
For this we need to edit the templates, so let's open up `blog/templates/blog/base.html` and change it so the part between the `<body>` tags looks like this:
<a href="{% url 'post_draft_list' %}" class="top-menu">{% include './icons/pencil-square.svg'%}</a>
113
+
{% else %}
114
+
<a href="{% url 'login' %}" class="top-menu">{% include './icons/lock-fill.svg' %}</a>
115
+
{% endif %}
116
+
<h1><a href="/">Django Girls Blog</a></h1>
117
+
</div>
118
+
</header>
119
+
<main class="content container">
116
120
<div class="row">
117
-
<div class="col-md-8">
118
-
{% block content %}
119
-
{% endblock %}
121
+
<div class="col">
122
+
{% block content %}
123
+
{% endblock %}
120
124
</div>
121
125
</div>
122
-
</div>
126
+
</main>
123
127
</body>
124
128
```
125
129
@@ -130,16 +134,20 @@ You might recognize the pattern here. There is an if-condition in the template t
130
134
Let's add some sugar to our templates while we're at it. First we will add some details to show when we are logged in. Edit `blog/templates/blog/base.html` like this:
<a href="{% url 'login' %}" class="top-menu">{% include './icons/lock-fill.svg' %}</a>
147
+
{% endif %}
148
+
<h1><a href="/">Django Girls Blog</a></h1>
149
+
</div>
150
+
</header>
143
151
```
144
152
145
153
This adds a nice "Hello _<username>_" to remind us who we are logged in as, and that we are authenticated. Also, this adds a link to log out of the blog -- but as you might notice this isn't working yet. Let's fix it!
@@ -161,6 +169,23 @@ urlpatterns = [
161
169
path('', include('blog.urls')),
162
170
]
163
171
```
172
+
Let's also add this to our `blog.css` file for the proper styling of our login:
173
+
174
+
```css
175
+
#logout {
176
+
font-family: 'Lobster', cursive;
177
+
178
+
}
179
+
180
+
smalla,
181
+
smalla:hover,
182
+
smalla:visited {
183
+
font-size: 15pt;
184
+
color: #ffffff;
185
+
text-decoration: none;
186
+
}
187
+
```
188
+

164
189
165
190
That's it! If you followed all of the above up to this point (and did the homework), you now have a blog where you
Copy file name to clipboardExpand all lines: en/homework/README.md
+11-12Lines changed: 11 additions & 12 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -21,7 +21,7 @@ Time to do something similar, but for draft posts.
21
21
Let's add a link in `blog/templates/blog/base.html` in the header. We don't want to show our list of drafts to everybody, so we'll put it inside the {% raw %}`{% if user.is_authenticated %}`{% endraw %} check, right after the button for adding new posts.
0 commit comments