So if I've got code like this:

    if (search_query['organisation']!=""):
        jobs = jobs.filter(organisation=search_query['organisation'])
    if (search_query['region']!=""):
        jobs = jobs.filter(region=search_query['region'])
    if (search_query['category']!=""):
        jobs = jobs.filter(category=search_query['category'])

and I want to remove the redundancy - what's a nice idiomatic Django
way to do it?

If Django used a more Pythonic syntax for Queryset filers (something
like jobs=jobs.filter('field', 'value') ) then it would be simple but
this with this - may I say - still slightly 'magic' approach I'm not
sure how one would go about replacing the left hand side of the filter
clause without dropping down to some of the SQL helper methods.


--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to