Hello, I've just uploaded a snippet for specifying Django query filters using a nested list syntax. This representation enables query filters to be built by a client-side JavaScript application and sent to a server app using JSON.
The code included in the snippet transforms this query filter specification into a Q filter object suitable for use in standard Django queries, like this: # request.POST['filter'] = '["and", ["in", "id", [1, 2, 5]], ["not", ["range", "date", ["2008-02-12", "2008-02-20"]]]]' from django.utils import simplejson filterSpec = simplejson.loads(request.POST['filter']) q = build_query_filter_from_spec(filterSpec) result_set = Thing.objects.filter(q) All of Django's primitive filter operators ("contains", "range", "in", ...) are supported, in addition to "not", "or", and "and" boolean operators. Django's existing query filter mechanism made this code pretty straightforward and concise. http://www.djangosnippets.org/snippets/676/ I hunted around for a while, but I didn't see any existing code that implemented this functionality. --Mike --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~----------~----~----~----~------~----~------~--~---