diff --git a/samplesite/bboard/templates/index.html b/samplesite/bboard/templates/index.html
new file mode 100644
index 0000000..8860998
--- /dev/null
+++ b/samplesite/bboard/templates/index.html
@@ -0,0 +1,17 @@
+
+
+
+
+ Главная :: Доска объявлений
+
+
+ Объявления
+ {% for bb in bbs %}
+
+
{{ bb.title }}
+
{{ bb.content }}
+
{{ bb.published|date:"d.m.y H:i:s" }}
+
+ {% endfor %}
+
+
\ No newline at end of file
diff --git a/samplesite/bboard/views.py b/samplesite/bboard/views.py
index 22e2791..5cd76da 100644
--- a/samplesite/bboard/views.py
+++ b/samplesite/bboard/views.py
@@ -1,9 +1,7 @@
-from django.http import HttpResponse
+from django.shortcuts import render
from .models import Bb
def index(request):
- s = 'Список объявлений \r\n\r\n\r\n'
- for bb in Bb.objects.order_by('-published'):
- s += bb.title + '\r\n' + bb.content + '\r\n\r\n'
- return HttpResponse(s, content_type = 'text/plain; charset=utf-8')
+ bbs = Bb.objects.order_by('-published')
+ return render(request, 'index.html', {'bbs': bbs})
\ No newline at end of file
diff --git a/samplesite/samplesite/settings.py b/samplesite/samplesite/settings.py
index 4f76ea5..88e740f 100644
--- a/samplesite/samplesite/settings.py
+++ b/samplesite/samplesite/settings.py
@@ -10,6 +10,7 @@ For the full list of settings and their values, see
https://docs.djangoproject.com/en/4.1/ref/settings/
"""
+import os
from pathlib import Path
# Build paths inside the project like this: BASE_DIR / 'subdir'.
@@ -55,7 +56,9 @@ ROOT_URLCONF = 'samplesite.urls'
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
- 'DIRS': [],
+ 'DIRS': [
+ os.path.join(BASE_DIR, 'bboard/templates'),
+ ],
'APP_DIRS': True,
'OPTIONS': {
'context_processors': [