Skip to content

Instantly share code, notes, and snippets.

View mateuszpohl's full-sized avatar
⚔️

Mateusz Pohl mateuszpohl

⚔️
View GitHub Profile
@mateuszpohl
mateuszpohl / SimpleFilteringListView.py
Created January 26, 2012 21:38
Django generic list view with simple filtering
from django.views.generic import ListView
class SimpleFilteringListView(ListView):
"""
List view with extra filtering and grouping in context data.
``filters`` dict is created as follows: {'context_variable_name', 'filtering_object_method_name'}
It calls filtering method on each object in object_list and if it returns True - this object is added
to proper context variable.