I have a product category ListView when I navigate to a specific directory DetailView
In the directory I load the related goods through product_set.all I need to do pagination for products
Catalog and products 2 different applications but they are connected. The directory includes ideas about the list of categories and one category and the app products is one representation of the product that is DetailView
Code categories
app_name = 'catalog'
mapping includes = [
path(", CategoriesList.as_view(), name='categories_list'),
path('<str:slug>/', CategoryDetail.as_view(), name='category_detail'),
]
class CategoriesList(ListView):
model = Category
context_object_name = 'categories'
template_name = 'catalog/categories_list.html'
class CategoryDetail(DetailView):
model = Category
template_name = 'catalog/category_detail.html'
Product code
app_name = 'product'
mapping includes = [
# Redirect to the directory
path(", RedirectView.as_view(url='/catalog/')),
path('<str:slug>/', ProductDetail.as_view(), name='detail'),
]
class ProductDetail(DetailView):
"""Product"""
model = Product
template_name = 'products/products_detail.html'
def get_context_data(self, **kwargs):
"""Add view of the form comment"""
context = super().get_context_data(**kwargs)
context['comment_form'] = CommentForm()
return context
And now the questions
1) it is Better to override the DetailView a directory in the ListView and do the pagination?
1.1), Then the logic in what application should it be in view because this is a list of products and category
2) Make pagination in DetailView, then tell me how to do it, preferably in detail. I watched the answers and code but I can not understand how it works here are the links
-
https://stackoverflow.com/questions/25569551/pagin...
-
https://gist.github.com/nspo/5ab1ecde7e918a5fa2662...
-
https://www.reddit.com/r/django/comments/6tdavj/he...