encode / django-vanilla-views

Beautifully simple class-based views.
http://django-vanilla-views.org/
BSD 2-Clause "Simplified" License
985 stars 74 forks source link

Add filtering support #40

Closed carltongibson closed 9 years ago

carltongibson commented 9 years ago

I'd like to add better support for filtering, similar to DRF. I have in mind Django Filter but a more generic filter backend interface would do too.

I've found first needing to implement get_context_data to pass the filter to the template. No problem here really.

But then in order to support pagination I have to implement get_paginator:

def get_paginator(self, queryset, page_size):
    return Paginator(self.filter, page_size)

filter here is a property, lazily instantiating the filter instance — I need it there because I still need the filter in the template.

Again, no real problem but it would be nice to just specify a filter_class, or filter_fields maybe... — in reality I'd guess most cases would merit a get_filter implementation, to get the customised filter instance — and have it Just Work™

The is kind of relevant to tomchristie/django-rest-framework#2180, where we need to keep the filter backends around in order to pass them to the template.

I'm happy to do all this if it's acceptable.

carltongibson commented 9 years ago

As per #39.

ayushin commented 2 years ago

I think adding an overridable filter_queryset() into get would add a lot of flexibility

adamchainz commented 2 years ago

Please don't comment on 6 year old issues that were closed with a sensible resolution.