Skip to content

Latest commit

History

133 Commits

Folders and files

NameName
Last commit message
Last commit date

Repository files navigation

"""
*Refactoring 6/2011*
Allowing users to display columns has always been a problem because when
there are changes to models, the introspection might auto-include undesired
things.
We're going to move the display column inclusions to an admin-like interface
where report administrators can establish what fields and attributes users
can select during their report generation.
* Down the road *
1.4 - ChangeList - https://code.djangoproject.com/ticket/5833
This ticket unlocked the admin changelist in a way very similar to Gaynor's
efforts. I collaborated with the devs to make sure that features which weren't
possible in Gaynor's django-filters were addressed, which was the reason I whipped up https://github.com/subsume/django-qfilters. As of 1.4 you can just use contrib.admin)
"""
# EXAMPLE SETUP:
#forms.py - Establish a django filterset a la class CustomFilterSet(FilterSet): # See notes about this in filters.py
address__zip = CommaFilter(label="Zip")
disability = DisabilityFilter(queryset=bm.Disability.objects.all(),label="Disability")
filter_overrides = {
models.DateField: {
'filter_class': bfilters.DateSpecificRangeFilter
},
models.PositiveIntegerField:{
'filter_class': django_filters.RangeFilter
},
models.ForeignKey : {
'filter_class': django_filters.ModelMultipleChoiceFilter,
'extra': lambda f: {
'queryset': f.rel.to._default_manager.complex_filter(f.rel.limit_choices_to),
'to_field_name': f.rel.field_name, }
},
models.CharField : {
'filter_class': django_filters.MultipleChoiceFilter,
'extra': lambda f: {'choices': f.choices, }
},
}
class Meta:
model = Customer
fields = ['race',
'location',
'household_annual_income',
'gender',
'address__zip_link__counties',
'employment_status',
'household_type',
'entry_date',
'closure_date',
'is_veteran',
'status',
'goals__type',
'goals__service__type',
'contact__program',
'contact__date',
'consumertag__tag',
'address__zip',]
#report.py
from django_customreport.sites import ReportSite as BaseReportSite
class ReportSite(BaseReportSite):
queryset = SomeQueryset.objects.all()
filterset_class = SomeFilterSet
displayset_class = SomeDisplaySet
site = ReportSite()
# urls.py
from my.report import site
urlpatterns = patterns('',
url('^my-report/$', include(site.urls)),
)

About

A library which allows one to create custom reports which filter and display any fields/relations on a model

Resources

Stars

9 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages