» tagged pages
» logout

sorted by: recent | see : popular
Content Tagged with django + Ajax

Pythoneer " JSON serialization for Django improved and simplified

I'm loving this. Saw the same shortcomings in Django's JSON serializer. Glad he has a simple alternative.

json: del.icio.us/tag/json

Django and ExtJS Grids with Filters

Are you an ExtJS and Django user? If so, you will want to check out this article by Matt of Tangible Worldwide on Using ExtJS's Grid Filtering with Django.

He goes into detail on how to tweak the grid filtering system that is aimed at PHP, and getting it to work in a way that allows you to write this Django code:

PYTHON:
  1.  
  2. # take a ContentType model name (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 set of POSTed filtering parameters
  9. filter_params = request.POST.get('q', '[]')
  10.  
  11. # decode the filtering parameters w/ simplejson
  12. filter_params = simplejson.loads(filter_params)
  13.  
  14. # apply the filtering params
  15. filtered_qs = get_queryset_from_ext_filters(obj_qs, filter_params)
  16.  

ExtJS 2.1 saw inclusion of the popular (at least in my world) user extension for AJAX filtering of data by grid columns. As useful as this is (provided you can abide by the GPL or paid licensing options), the filter parameters serialized as a PHP array, which is not particularly useful for other languages. With a quick modification to the grid filtering serialization method and a helper function for Django, we can rewire the system to send a JSON string that Django can use to directly apply filtering to a QuerySet. I've found that most clients love having this sort of command and flexibility over their data -- especially the kind that don't necessarily realize that this visualization and control exists. I like that. Additionally, the amount of work and code required is minimal, and the code both reusable and straight-forward. I like that, too.

There are 4 steps to this process:

  1. Modify the serialization method in GridFilters.js
  2. Set up the helper function that will process the QuerySet with the grid filter parameters
  3. Slightly customize your models (see below)
  4. Add (simple) helper code to your Ajax view

Ajax: Ajaxian

Home | The Dojo Toolkit

Ajax, events, packaging, CSS-based querying, animations, JSON, language utilities, and a lot more. All at 24K (gzipped).

Dojo: del.icio.us tag dojo

Dojo Campus

With the release of dojango, I figured it might be a good idea to learn dojo.....

Dojo: del.icio.us tag dojo

Django tips: A simple AJAX example, part 1

return HttpResponse(simplejson.dumps(response_dict), mimetype='application/javascript')

json: del.icio.us/tag/json

Django snippets: Snippets by kcarnold

RESTy, AJAXixal dajngo views on the fly, middleware style

json: del.icio.us/tag/json

Django snippets: Snippets by kcarnold

Packed with AJAX/JSON Django goodness. Includes JSON middleware (just return a dictionary)!

json: del.icio.us/tag/json

Page 1 | Next >>