init
This commit is contained in:
parent
4ada78aa74
commit
4439bb6d46
3 changed files with 24 additions and 6 deletions
17
samplesite/bboard/templates/index.html
Normal file
17
samplesite/bboard/templates/index.html
Normal file
|
@ -0,0 +1,17 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>Главная :: Доска объявлений</title>
|
||||
</head>
|
||||
<body>
|
||||
<h1>Объявления</h1>
|
||||
{% for bb in bbs %}
|
||||
<div>
|
||||
<h2>{{ bb.title }}</h2>
|
||||
<p>{{ bb.content }}</p>
|
||||
<p>{{ bb.published|date:"d.m.y H:i:s" }}</p>
|
||||
</div>
|
||||
{% endfor %}
|
||||
</body>
|
||||
</html>
|
|
@ -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})
|
|
@ -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': [
|
||||
|
|
Loading…
Add table
Reference in a new issue