>From reading the documentation on generic views, I don't seem to be
making much head way. Basically I'm looking to create a paginated page
displaying all products within a specific category.
Within my urls.py I call the category view within my app:
(r'^category/(?P<category_id>\d+)/$', 'eshop.shop.views.category'),
My category view then looks like this:
from django.views.generic.list_detail import object_list
from eshop.shop.models import Category, Product
def category(request, category_id):
category = Category.objects.filter(id=category_id)
products = Product.objects.filter(category=category_id)
category_count = category.count()
product_count = products.count()
return object_list(request, queryset=products,
template_object_name='products', paginate_by=1,
template_name='category.html', extra_context={'category':category,
'category_count':category_count, 'product_count':product_count,
'category_id':category_id})
Within the template when I conditionally check for products or
categories nothing is executed, despite returning a product count of
4, and a category count of 1.
Am I missing something glaringly obvious, its driving me mad!
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---