Monday, January 20, 2014

Re: Combining django-tables2 with django-filter info ListView?

Were you able to implement it? Could you help me?

On Thursday, August 9, 2012 3:47:56 PM UTC-5, Paul wrote:
I have a listview using the generic class based ListView. I have get_queryset overloaded in my view:

class WebsiteList(ListView):
    model = Website
    def get_queryset(self):
        return Website.objects.all()

First step is to add the tables2 mixin as follows:

class WebsiteList(tables.SingleTableMixin, ListView):
    model = Website
    table_class = WebsiteTable     #tables2 related
    def get_queryset(self):
        return Website.objects.all()

The mixin adds the table object to the context and adds an order_by clause to the queryset.

Now i don't know how to add a second mixin for django-filter; i have a mixin available but since it also fetches the queryset from get_queryset i'm expecting that either the ordering or the filtering won't work!?

Anyone with mixin experience willing to give some directions?

Paul

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/5d1bb27d-5afc-4ce8-9f61-4dca34027341%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

No comments:

Post a Comment