Hello guys I am receiving this error :
This my main URL:
urlpatterns = [
path('admin/', admin.site.urls),
path('blog/',include('blog.urls',namespace='blog')),
]
My blog/url.py:
app_name = 'blog'
urlpatterns = [
path('',views.PostListView.as_view(), name='post_list'),
path('<int:year>/<int:month>/<int:day>/<int:post>',views.post_detail,name='post_detail'),
]
view.py:
class PostListView(ListView):
queryset = Post.published.all()
context_object_name = 'posts'
paginate_by = 3
template_name = 'blog/post/list.html'
def post_list(request):
posts = Post.published.all()
return render(request, 'blog/post/list.html', {'posts': posts})
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/detail.html', {'post': post})
list.html:
{% extends "blog/base.html" %}
{% block title %}My Blog{% endblock %}
{% block content %}
<h1>My Blog</h1>
{% for post in posts %}
<h2><a href="{{ post.get_absolute_url }}">{{ post.title }}</a></h2>
<p class="date">Published {{ post.publish }} by {{ post.author }}</p>
{{ post.body|truncatewords:30|linebreaks }}
{% endfor %}
{% include "pagination.html" with page=page_obj %}
{% endblock %}
I don't know what is the problem with the code. I need some help please.