Skip to content

Commit cc63dfe

Browse files
committed
Add templates
1 parent 012c170 commit cc63dfe

File tree

20 files changed

+147
-175
lines changed

20 files changed

+147
-175
lines changed
Lines changed: 23 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,26 @@
11
{% load static %}
22
<!DOCTYPE html>
33
<html lang="en">
4-
5-
<head>
6-
<meta charset="UTF-8">
7-
<title>My Diary</title>
8-
<link rel="stylesheet" href="{% static 'css/diary.css' %}">
9-
</head>
10-
11-
<body>
12-
<h1><a href="/">Dear diary …</a></h1>
13-
14-
{% if messages %}
15-
<ul class="messages">
16-
{% for message in messages %}
17-
<li class="message">
18-
{{ message }}
19-
</li>
20-
{% endfor %}
21-
</ul>
22-
{% endif %}
23-
24-
{% block content %}{% endblock %}
25-
26-
<hr>
27-
<a href="{% url 'admin:logout' %}">Logout</a>
28-
</body>
29-
30-
</html>
4+
<head>
5+
<meta charset="UTF-8">
6+
<title>My Diary</title>
7+
<link rel="stylesheet" href="{% static 'css/diary.css' %}">
8+
</head>
9+
<body>
10+
<h1>
11+
<a href="/">Dear diary …</a>
12+
</h1>
13+
{% if messages %}
14+
<ul class="messages">
15+
{% for message in messages %}<li class="message">{{ message }}</li>{% endfor %}
16+
</ul>
17+
{% endif %}
18+
{% block content %}
19+
{% endblock content %}
20+
<hr>
21+
<form method="post" action="{% url 'admin:logout' %}">
22+
{% csrf_token %}
23+
<input type="submit" value="Logout" />
24+
</form>
25+
</body>
26+
</html>
Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
11
{% extends "entries/base.html" %}
22
{% block content %}
3-
<form method="post">{% csrf_token %}
3+
<form method="post">
4+
{% csrf_token %}
45
<p>
5-
Are you sure you want to delete <em>"{{ entry.title }}"</em><br>
6+
Are you sure you want to delete
7+
<em>"{{ entry.title }}"</em>
68
created on {{ entry.date_created|date:'Y-m-d' }}?
79
</p>
810
<input type="submit" value="Confirm">
911
</form>
1012
<a href="{% url 'entry-detail' entry.id %}">
1113
<button>Cancel</button>
1214
</a>
13-
{% endblock %}
15+
{% endblock content %}
Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,12 @@
11
{% extends "entries/base.html" %}
2-
32
{% block content %}
43
<article>
54
<h2>{{ entry.date_created|date:'Y-m-d H:i' }}</h2>
65
<h3>{{ entry.title }}</h3>
76
<p>{{ entry.content }}</p>
87
</article>
9-
10-
<p>
11-
<a href="{% url 'entry-update' entry.id %}">✍️ Edit</a>
12-
<a href="{% url 'entry-delete' entry.id %}">⛔ Delete</a>
13-
</p>
14-
{% endblock %}
8+
<p>
9+
<a href="{% url 'entry-update' entry.id %}">✍️ Edit</a>
10+
<a href="{% url 'entry-delete' entry.id %}">⛔ Delete</a>
11+
</p>
12+
{% endblock content %}
Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,17 @@
11
{% extends "entries/base.html" %}
22
{% block content %}
3-
<form method="post">{% csrf_token %}
3+
<form method="post">
4+
{% csrf_token %}
45
{{ form.as_p }}
56
<input type="submit" value="Save">
67
</form>
78
{% if entry %}
89
<a href="{% url 'entry-detail' entry.id %}">
9-
<button>Cancel</button>
10+
<button>Cancel</button>
1011
</a>
1112
{% else %}
1213
<a href="{% url 'entry-list' %}">
13-
<button>Cancel</button>
14+
<button>Cancel</button>
1415
</a>
1516
{% endif %}
16-
{% endblock %}
17+
{% endblock content %}
Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,19 @@
11
{% extends "entries/base.html" %}
2-
32
{% block content %}
43
<article>
5-
<h2 class="mark">{% now "Y-m-d H:i" %}</em></h2>
6-
<a href="{% url 'entry-create' %}"><button>Add new entry</button></a>
4+
<h2 class="mark">
5+
{% now "Y-m-d H:i" %}</em>
6+
</h2>
7+
<a href="{% url 'entry-create' %}">
8+
<button>Add new entry</button>
9+
</a>
10+
</article>
11+
{% for entry in entry_list %}
12+
<article>
13+
<h2 class="{{ entry.date_created|date:'l' }}">{{ entry.date_created|date:'Y-m-d H:i' }}</h2>
14+
<h3>
15+
<a href="{% url 'entry-detail' entry.id %}">{{ entry.title }}</a>
16+
</h3>
717
</article>
8-
{% for entry in entry_list %}
9-
<article>
10-
<h2 class="{{ entry.date_created|date:'l' }}">
11-
{{ entry.date_created|date:'Y-m-d H:i' }}
12-
</h2>
13-
<h3>
14-
<a href="{% url 'entry-detail' entry.id %}">
15-
{{ entry.title }}
16-
</a>
17-
</h3>
18-
</article>
19-
{% endfor %}
20-
{% endblock %}
18+
{% endfor %}
19+
{% endblock content %}

django-diary/source_code_step_3/entries/templates/entries/entry_detail.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22
<h2>{{ entry.date_created|date:'Y-m-d H:i' }}</h2>
33
<h3>{{ entry.title }}</h3>
44
<p>{{ entry.content }}</p>
5-
</article>
5+
</article>
Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,8 @@
11
{% for entry in entry_list %}
22
<article>
3-
<h2 class="{{ entry.date_created|date:'l' }}">
4-
{{ entry.date_created|date:'Y-m-d H:i' }}
5-
</h2>
3+
<h2 class="{{ entry.date_created|date:'l' }}">{{ entry.date_created|date:'Y-m-d H:i' }}</h2>
64
<h3>
7-
<a href="{% url 'entry-detail' entry.id %}">
8-
{{ entry.title }}
9-
</a>
5+
<a href="{% url 'entry-detail' entry.id %}">{{ entry.title }}</a>
106
</h3>
117
</article>
12-
{% endfor %}
8+
{% endfor %}
Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,16 @@
11
{% load static %}
22
<!DOCTYPE html>
33
<html lang="en">
4-
5-
<head>
6-
<meta charset="UTF-8">
7-
<title>My Diary</title>
8-
<link rel="stylesheet" href="{% static 'css/diary.css' %}">
9-
</head>
10-
11-
<body>
12-
<h1><a href="/">Dear diary …</a></h1>
13-
14-
{% block content %}{% endblock %}
15-
16-
</body>
17-
18-
</html>
4+
<head>
5+
<meta charset="UTF-8">
6+
<title>My Diary</title>
7+
<link rel="stylesheet" href="{% static 'css/diary.css' %}">
8+
</head>
9+
<body>
10+
<h1>
11+
<a href="/">Dear diary …</a>
12+
</h1>
13+
{% block content %}
14+
{% endblock content %}
15+
</body>
16+
</html>
Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
{% extends "entries/base.html" %}
2-
32
{% block content %}
43
<article>
54
<h2>{{ entry.date_created|date:'Y-m-d H:i' }}</h2>
65
<h3>{{ entry.title }}</h3>
76
<p>{{ entry.content }}</p>
87
</article>
9-
{% endblock %}
8+
{% endblock content %}
Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,11 @@
11
{% extends "entries/base.html" %}
2-
32
{% block content %}
43
{% for entry in entry_list %}
54
<article>
6-
<h2 class="{{ entry.date_created|date:'l' }}">
7-
{{ entry.date_created|date:'Y-m-d H:i' }}
8-
</h2>
5+
<h2 class="{{ entry.date_created|date:'l' }}">{{ entry.date_created|date:'Y-m-d H:i' }}</h2>
96
<h3>
10-
<a href="{% url 'entry-detail' entry.id %}">
11-
{{ entry.title }}
12-
</a>
7+
<a href="{% url 'entry-detail' entry.id %}">{{ entry.title }}</a>
138
</h3>
149
</article>
1510
{% endfor %}
16-
{% endblock %}
11+
{% endblock content %}

0 commit comments

Comments
 (0)