I am working on a blog development in Django and there are different categories of posts or articles on category_list.html which have been created using ORM library and to each category i have added some articles using ORM library with the help of category slug which are rendered on category_view.html and problem is that list of categories are shown perfectly on category_list.html after adding from admin panel of django and when I click on any category name(contains get_absolute_url link), it takes me perfectly to category_view.html page but on category_view.html, data is shown in the form of text means renders the complete content of category_view.html in the form of plain text. All other templates are getting rendered by django perfectly but what is the reason that category_view.html is getting rendered as plain text? Please help me
def category_list(request,category_slug=None):
category=None
categories=CategoryList.objects.all()
# article=Article.objects.all()
return render(request,'category_list.html',{'categories':categories})
def category_view(request,category_slug):
category=get_object_or_404(CategoryList,slug=category_slug)
article=Article.objects.filter(category=category)
return render(request,'category_view.html',{'category':category},{'article':article})
My url.py contains the following urls:
path("",views.index),
path('category',views.category_list, name='category_list'),
path('<slug:category_slug>',views.category_view, name='story_by_category'),
This is link in category_list.html which takes me to category_view.html
<div class="row py-3">
{%for c in categories%}
<div class="col-lg col-12 homeimg" id="img1">
<h5><a href="{{c.get_absolute_url}}">{{c.name}}</a></h5>
<img class="secimg border-info" src="{{c.image_url|default_if_none:'#'}}" alt="gameplay
videos">
</div>
{%endfor%}
</div>