Skip to main content

Neat QuerySet filter for django apps with filterforms based on django forms

Project description

Abstract

Library for django-powered websites to implement data filtering without gore.

This library provides decorator for django views (filter_powered) and small framework to create so-called FilterForm classes that declaratively define filter specifications.

This approach is somewhat differs from one in django-admin, but it looks much more intuitive and straightforward imho.

Main limitation of filter_powered

Views that “powered” with filter expected to return either SimpleTemplateResponse subclass (that was introduced in Django 1.3) or bare context dictionaries (to get the context and data to filter) so decorator returns the same type that was passed into it.

Other types (HttpResponse it common case) are silently ignored and bypassed by decorator.

As mentioned above, if one want to use filter_powered decorator with older django, he have to implement some decorator to put above that will actually render context. It should be something like that:

@render_to("foo/bar.html")
def bar(request):
    some_result = do_smth(request)
    return {'result': some_result}

render_to decorator implementation is trivial and therefore omitted. In such way we can hook anything between render_to and template context and thus isolate common context processing tasks (like filtering) and reuse them.

Requirements

  • Django (1.3 to use SimpleTemplateResponse, but 1.2 will be also just fine, see above);

  • django-forms-extras for some of builtin specifications.

TODO: Examples, more info about FilterForm, FilterSpec and filter_powered.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

datafilters-0.1.1.tar.gz (6.9 kB view hashes)

Uploaded Source

Built Distribution

datafilters-0.1.1-py2.7.egg (24.2 kB view hashes)

Uploaded Source

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page