Answer the question
In order to leave comments, you need to log in
How to correctly compose the path of the page model if there are child pages?
There is a page model
class Page(models.Model):
"""Модель Страницы"""
title = models.CharField(max_length=20, verbose_name='Заголовок')
slug = models.SlugField(unique=True, verbose_name='Дружественный URL')
parent = models.ForeignKey('self', on_delete=models.CASCADE, blank=True, null=True, related_name='children', verbose_name='Родительская страница')
class PageView(DetailView):
model = Page
context_object_name = 'page'
template_name = 'core/page.html'
queryset = Page.objects.filter(published=True, hidden_menu=False)
path('<slug>/', PageView.as_view(), name='page'),
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