New files
templates/app/home.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Djangocourse</title>
</head>
<body>
<h1>Articles</h1>
<ul>
{% for article in articles %}
<li>{{ article.title }} with {{ article.word_count }} words.</li>
{% endfor %}
</ul>
</body>
</html>
Modified files
app/views.py
---
+++
@@ -1,4 +1,7 @@
-from django.http import HttpResponse
+from django.shortcuts import render
+from app.models import Article
+
def home(request):
- return HttpResponse("Hello, World!")+ articles = Article.objects.all()
+ return render(request, "app/home.html", {"articles": articles})
djangocourse/settings.py
---
+++
@@ -55,7 +55,7 @@
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
- 'DIRS': [],
+ 'DIRS': [BASE_DIR / "templates"],
'APP_DIRS': True,
'OPTIONS': {
'context_processors': [