Answer the question
In order to leave comments, you need to log in
How to throw a 404 error if a non-existent link passed regex in urls.py?
Good evening!
Dealt with non-existent pages. But what about categories? You can edit the link in the field and voila - the regular expression check passes, but does not exist in the database. And how to filter?
I wanted to make a filter by the parent slug link that is in the model, but apparently you can only filter by your own fields.
At the moment such a view.
def articles_list(request, category_slug):
articles = get_list_or_404(Article.objects.order_by('name'))
context = {
'articles': articles
}
return render(request, 'my_app/articles_list.html', context)
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question