On Fri, May 9, 2008 at 6:19 PM, Greg Fuller <[EMAIL PROTECTED]> wrote:
>
> Hello,
>
> I'm trying to build filter strings dynamically.
>
> The normal way works:
>    qry = qry.filter(sections__name__exact='printing')
>
> This does not work:
>    filter_str = "sections__name__exact='shooting'"
>    qry = qry.filter(filter_str)
> .
> The error is "too many values to unpack" at django/db/models/sql/
> query.py in add_filter, line 933
>
> I realize something outside normal name-spacing is probably happening,
> since "sections__name__exact"  doesn't have to be defined anywhere.
>
> But is there any way to build the parameter to the filter dynamically?

the usual python way of building dynamic args:

filter = {'sections__name__exact': 'shooting'}
qry = qry.filter(**filter)

-- 
John Lenton ([EMAIL PROTECTED]) -- Random fortune:
The trouble with a lot of self-made men is that they worship their creator.

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