Skip to main content

django-refinery

Allows users to filter down a queryset based on a model’s fields, similar to the Django admin’s list_filter interface. A FilterTool helper class is provided, which will (by default) map filters to model fields and create a form for queryset manipulation. The helper class supports an interface which will feel familiar to anyone who’s used a Django ModelForm.

Author:

Jacob Radford

Licence:

BSD

Example usage

Given a Product model you could create a FilterTool for it with:

import refinery

class ProductFilterTool(refinery.FilterTool):
    class Meta:
        model = Product
        fields = ['name', 'price']

And then in your view you could do:

def product_list(request):
    filtertool = ProductFilterTool(request.GET or None)
    return render_to_response('product/product_list.html',
        {'filtertool': filtertool})

And then in your template:

<form action="" method="get">
    {{ filtertool.form.as_p }}
    <input type="submit" />
</form>
<h2>Products</h2>
<ul>
  {% for obj in filtertool %}
      <li>{{ obj.name }} - ${{ obj.price }}</li>
  {% endfor %}
</ul>

For more complex usage or custom needs, refer to the project documentation.

Requirements

  • Python 2.5+

  • Django 1.3+

Installation

  • pip install -U django-refinery

  • Add refinery to your INSTALLED_APPS

To install the in-development version of django-refinery, run pip install django-refinery==dev.

Documentation

See the docs folder or read it on readthedocs for expanded information on:

  • Usage examples

  • Contributing

  • Integration with other apps

  • Project background

  • Low-level API

  • Creating custom filters

Bugs

If you want to help out with the development of django-refinery, by posting detailed bug reports, proposing new features, or suggesting documentation improvements, use the issue tracker. If you want to fix it yourself, thank you! Fork the project, make changes and send a pull request. Please do create an issue to discuss your plans.

Background

Django-refinery is based on django-filter, an application created by Alex Gaynor. For a complete project history and list of contributors, see the project documentation.

Roadmap

  • Overhaul and expand documentation

  • Overhaul and expand test suite

  • Refactor generic class view (look into pagination of ListView)

  • Allow integration of django-floppyforms

  • Allow integration of django-crispy-forms

  • Allow filters on non-required fields with choices to provide option of filtering the records that are unset. (i.e. FK is null)

  • Allow abstraction of ordering values used to avoid passing internal information in GET params (i.e. user__username)

  • Look into adapting LinkWidget and overall behavior to support filtering like django-easyfilters or maybe drop the widget?

Resources

Metadata

Release files for django-refinery 0.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for django-refinery 0.1
File Size Uploaded Provenance Actions
django-refinery-0.1.tar.gz 23.0 kB Without provenance Details for django-refinery-0.1.tar.gz

Release files / django-refinery-0.1.tar.gz

Download URL django-refinery-0.1.tar.gz
Size 23.0 kB
Tags Source
SHA-256 checksum
How to use checksums
413974bba999f2b115bf95a4fa2895c054b867e88f70cc03b33999ff640208b3
BLAKE2b-256 checksum
How to use checksums
89c0e6761667e8f45d913c8df67319285ab7eddacf3d7ade95fc67e501a44e45
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Security for django-refinery 0.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1 This release

1 release file No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page