django-refineryA reusable Django application for allowing users to filter queryset dynamically | |
Download |
django-refinery Ranking & Summary
Advertisement
- License:
- BSD License
- Price:
- FREE
- Publisher Name:
- Jacob Radford
- Publisher web site:
- http://github.com/nkryptic/
django-refinery Tags
django-refinery Description
django-refinery is a Django app that 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.Example usageGiven a Product model you could create a FilterTool for it with:import refineryclass ProductFilterTool(refinery.FilterTool): class Meta: model = Product fields = 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.Installation- pip install -U django-refinery- Add refinery to your INSTALLED_APPSTo install the in-development version of django-refinery, run pip install django-refinery==dev.Product's homepage
django-refinery Related Software