nkeric wrote: >I guess I need to build the 'queryset' of the article_list_dict >dynamically as something like >this: Article.object.filter(category__id__exact=<category_id>) rather >than Article.objects.all(). > >Is it possible? > > No it's currently not possible. There are two workarounds though.
1. You can use an object_detail view for category object urlpatterns = patterns('', (r'category/(?P<object_id>\d+)/$', 'django.views.generic.list_detail.object_detail', {'queryset': Category.objects.all()), ) ... and get an article list in template: {% for article in object.article_set.all %} {{ article }}<br> {% endfor %} The downside of this approach is that you can't have pagination that object_list view can provide. 2. If you need a pagination you can create your own simple generic view wrapping Django's object_list that adds some filters to the queryset: def filtered_list(request, object_id, filter_field, *args, **kwargs): lookup = {'%s__exact' % filter_field: object_id} kwargs['queryset'] = kwargs['queryset'].filter(**lookup) return object_list(request, *args, **kwargs) ... and use it in your urlconf like this: urlpatterns = patterns('', (r'category/(?P<object_id>\d+)/$', 'myproject.views.filtered_list', {'queryset': Article.objects.all(), 'filter_field': 'category_id'), ) --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users -~----------~----~----~----~------~----~------~--~---