Skip to content

Commit 1f77176

Browse files
committed
2 parents b66ac97 + af47407 commit 1f77176

File tree

14 files changed

+101
-105
lines changed

14 files changed

+101
-105
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,3 +105,6 @@ venv.bak/
105105

106106
# Exclude collected Django static files
107107
static_collected
108+
109+
# Exclude machine-specific vs code settings
110+
.vscode/settings.json

.vscode/settings.json

Lines changed: 0 additions & 3 deletions
This file was deleted.

hello/apps.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
from django.apps import AppConfig
22

3-
43
class HelloConfig(AppConfig):
54
name = 'hello'

hello/forms.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
from django import forms
2-
from .models import LogMessage
2+
3+
from hello.models import LogMessage
34

45
class LogMessageForm(forms.ModelForm):
56
class Meta:
67
model = LogMessage
7-
fields = ('message',) # NOTE: the trailing comma is required
8+
fields = ("message",) # NOTE: the trailing comma is required

hello/models.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22

33
class LogMessage(models.Model):
44
message = models.CharField(max_length=300)
5-
log_date = models.DateTimeField('date logged')
5+
log_date = models.DateTimeField("date logged")
66

7-
def __unicode__(self):
7+
def __str__(self):
88
"""Returns a string representation of a message."""
9-
return "'" + self.text + "' logged on " + log_date.strftime('%A, %d %B, %Y at %X')
9+
return f"'{self.message}' logged on {self.log_date.strftime('%A, %d %B, %Y at %X')}"

hello/templates/hello/about.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{% extends "hello/layout.html" %}
22
{% block title %}
3-
About
3+
About
44
{% endblock %}
55
{% block content %}
6-
<p>About page for the Visual Studio Code Django tutorial.</p>
6+
<p>About page for the Visual Studio Code Django tutorial.</p>
77
{% endblock %}

hello/templates/hello/contact.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{% extends "hello/layout.html" %}
22
{% block title %}
3-
Contact Us
3+
Contact Us
44
{% endblock %}
55
{% block content %}
6-
<p>Contact page for the Visual Studio Code Django tutorial.</p>
6+
<p>Contact page for the Visual Studio Code Django tutorial.</p>
77
{% endblock %}
Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
<!DOCTYPE html>
22
<html>
3-
<head>
4-
<meta charset="utf-8" />
5-
<title>Hello, Django</title>
6-
{% load static %}
7-
<link rel="stylesheet" type="text/css" href="{% static 'hello/site.css' %}" />
8-
</head>
9-
<body>
10-
<span class="message">Hello, there {{ name }}!</span> It's {{ date | date:'l, d F, Y' }} at {{ date | time:'H:i:s' }}.
11-
</body>
3+
<head>
4+
<meta charset="utf-8"/>
5+
<title>Hello, Django</title>
6+
{% load static %}
7+
<link rel="stylesheet" type="text/css" href="{% static 'hello/site.css' %}"/>
8+
</head>
9+
<body>
10+
<span class="message">Hello, there {{ name }}!</span> It's {{ date | date:'l, d F, Y' }} at {{ date | time:'H:i:s' }}.
11+
</body>
1212
</html>

hello/templates/hello/home.html

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,32 @@
11
{% extends "hello/layout.html" %}
22
{% block title %}
3-
Home
3+
Home
44
{% endblock %}
55
{% block content %}
6-
<h2>Logged messages</h2>
6+
<h2>Logged messages</h2>
77

8-
{% if message_list %}
9-
<table class="message_list">
10-
<thead>
11-
<tr>
12-
<th>Date</th>
13-
<th>Time</th>
14-
<th>Message</th>
15-
</tr>
16-
</thead>
17-
<tbody>
18-
{% for message in message_list %}
19-
<tr>
20-
<td>{{ message.log_date | date:'d M Y' }}</td>
21-
<td>{{ message.log_date | date:'H:i:s' }}</td>
22-
<td>
23-
{{ message.message }}
24-
</td>
25-
</tr>
26-
{% endfor %}
27-
</tbody>
28-
</table>
29-
{% else %}
30-
<p>No messages have been logged. Use the <a href="{% url 'log' %}">Log Message form</a>.</p>
31-
{% endif %}
8+
{% if message_list %}
9+
<table class="message_list">
10+
<thead>
11+
<tr>
12+
<th>Date</th>
13+
<th>Time</th>
14+
<th>Message</th>
15+
</tr>
16+
</thead>
17+
<tbody>
18+
{% for message in message_list %}
19+
<tr>
20+
<td>{{ message.log_date | date:'d M Y' }}</td>
21+
<td>{{ message.log_date | date:'H:i:s' }}</td>
22+
<td>
23+
{{ message.message }}
24+
</td>
25+
</tr>
26+
{% endfor %}
27+
</tbody>
28+
</table>
29+
{% else %}
30+
<p>No messages have been logged. Use the <a href="{% url 'log' %}">Log Message form</a>.</p>
31+
{% endif %}
3232
{% endblock %}

hello/templates/hello/layout.html

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,27 @@
11
<!DOCTYPE html>
22
<html>
3-
<head>
4-
<meta charset="utf-8" />
5-
<title>{% block title %}{% endblock %}</title>
6-
{% load static %}
7-
<link rel="stylesheet" type="text/css" href="{% static 'hello/site.css' %}" />
8-
</head>
3+
<head>
4+
<meta charset="utf-8"/>
5+
<title>{% block title %}{% endblock %}</title>
6+
{% load static %}
7+
<link rel="stylesheet" type="text/css" href="{% static 'hello/site.css' %}"/>
8+
</head>
99

10-
<body>
11-
<div class="navbar">
12-
<a href="{% url 'home' %}" class="navbar-brand">Home</a>
13-
<a href="{% url 'log' %}" class="navbar-item">Log Message</a>
14-
<a href="{% url 'about' %}" class="navbar-item">About</a>
15-
<a href="{% url 'contact' %}" class="navbar-item">Contact</a>
16-
</div>
10+
<body>
11+
<div class="navbar">
12+
<a href="{% url 'home' %}" class="navbar-brand">Home</a>
13+
<a href="{% url 'log' %}" class="navbar-item">Log Message</a>
14+
<a href="{% url 'about' %}" class="navbar-item">About</a>
15+
<a href="{% url 'contact' %}" class="navbar-item">Contact</a>
16+
</div>
1717

18-
<div class="body-content">
19-
{% block content %}
20-
{% endblock %}
21-
<hr/>
22-
<footer>
23-
<p>&copy; 2018</p>
24-
</footer>
25-
</div>
26-
</body>
18+
<div class="body-content">
19+
{% block content %}
20+
{% endblock %}
21+
<hr/>
22+
<footer>
23+
<p>&copy; 2018</p>
24+
</footer>
25+
</div>
26+
</body>
2727
</html>

0 commit comments

Comments
 (0)