def post_detail(request, year, month, day, post):--
post = get_object_or_404(Post, slug=post,
status='published',
publish__year=year,
publish__month=month,
publish__day=day)
return render(request,
'blog/post/details.html',
{'post': post})
--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users...@googlegroups.com.
To post to this group, send email to django...@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CACiphSVVyMgpNmgFj16ROZGqpohaq0fYJKV2bES4D1aVeg1LbA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
"It's when nothing happens that anything can happen."
https://kodenaut.github.io/
+254 723494571
from django.shortcuts import render, get_object_or_404
from django.core.paginator import Paginator, EmptyPage, PageNotAnInteger
from django.views.generic import ListView
from .models import Post
def post_list(request):
object_list = Post.published.all()
paginator = Paginator(object_list, 3) # 3 posts in each page
page = request.GET.get('page')
try:
posts = paginator.page(page)
except PageNotAnInteger:
# If page is not an integer deliver the first page
posts = paginator.page(1)
except EmptyPage:
# If page is out of range deliver last page of results
posts = paginator.page(paginator.num_pages)
return render(request,
'blog/post/list.html',
{'page': page,
'posts': posts})
# Create your views here.
def post_detail(request, year, month, day, post):
post = get_object_or_404(Post, slug=post,
status='published',
publish__year=year,
publish__month=month,
publish__day=day)
return render(request,
'blog/post/details.html',
{'post': post})
class PostListView(ListView):
queryset = Post.published.all()
context_object_name = 'posts'
paginate_by = 3
template_name = 'blog/post/list.html'
def test_test(request):
return render(request,'blog/post/test.html')
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CACYP3VGYe96j6vYWYC8-7GCzODUfu8b5xc1qo2Lh6KhHevKgYQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CACiphSUvx06-PwJpxxMWyaKce_CTRagh4JDmkm3Mm-4j5UR-4Q%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CACYP3VGYe96j6vYWYC8-7GCzODUfu8b5xc1qo2Lh6KhHevKgYQ%40mail.gmail.com.
post = get_object_or_404(Post, slug=post,
status='published',
publish__year=year)
# publish__month=month,
# publish__day=day)
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CACiphSUvx06-PwJpxxMWyaKce_CTRagh4JDmkm3Mm-4j5UR-4Q%40mail.gmail.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CADnU5JGNUM1NA-1pUo-33OFECVXB-JEA%2BB7D794vMNt%2Byh0xDg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.