You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
20 lines
631 B
20 lines
631 B
from django.shortcuts import render, get_object_or_404 |
|
from django.http import HttpResponse |
|
|
|
from .models import Post |
|
|
|
import re |
|
|
|
|
|
def index(request): |
|
"""Список постов.""" |
|
post_list = Post.objects.order_by("-pub_date")[:20] |
|
return render(request, "posts/index.html", {"posts": post_list}) |
|
|
|
|
|
def detail(request, post_id): |
|
"""Страница с просмотром поста.""" |
|
# вынести отсюда все. Также надо обработать текст поста тут. |
|
post = get_object_or_404(Post, pk=post_id) |
|
|
|
return render(request, "posts/post.html", {"post": post})
|
|
|