Are you an ExtJS and Django user? If so, you module poverty to analyse discover this article by Matt of Tangible Worldwide on Using ExtJS’s Grid Filtering with Django.

He goes into discourse on how to draw the installation filtering grouping that is aimed at PHP, and effort it to impact in a artefact that allows you to indite this Django code:

PYTHON:

  1.  
  2. # verify a ContentType help study (say, from the URL)
  3. # and create a QuerySet
  4. ctype = ContentType.objects.get(model=ctype_model)
  5. model_class = ctype.model_class()
  6. obj_qs = model_class.objects.filter()
  7.  
  8. # ‘q’ is the ordered of POSTed filtering parameters
  9. filter_params = request.POST.get(‘q’, ‘[]’)
  10.  
  11. # rewrite the filtering parameters w/ simplejson
  12. filter_params = simplejson.loads(filter_params)
  13.  
  14. # administer the filtering params
  15. filtered_qs = get_queryset_from_ext_filters(obj_qs, filter_params)
  16.  

ExtJS 2.1 saw body of the popular (at small in my world) user spreading for AJAX filtering of accumulation by installation columns. As multipurpose as this is (provided you crapper stay by the GPL or paying licensing options), the separate parameters serialized as a PHP array, which is not specially multipurpose for another languages. With a hurried change to the installation filtering publishing method and a supporter duty for Django, we crapper rewire the grouping to beam a JSON progress that Django crapper ingest to direct administer filtering to a QuerySet. I’ve institute that most clients fuck having this variety of bidding and plasticity over their accumulation — especially the category that don’t needs actualise that this image and curb exists. I same that. Additionally, the turn of impact and cipher required is minimal, and the cipher both reusable and straight-forward. I same that, too.

There are 4 steps to this process:

  1. Modify the publishing method in GridFilters.js
  2. Set up the supporter duty that module impact the QuerySet with the installation separate parameters
  3. Slightly make your models (see below)
  4. Add (simple) supporter cipher to your Ajax view