Similarly, this will work also:field = 'sections' qry = qry.filter(**{field+'__name__exact': 'shooting'}) Cheers, Aaron John Lenton wrote: 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) --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~--- |
- Building filter strings dynamically Greg Fuller
- Re: Building filter strings dynamically John Lenton
- Re: Building filter strings dynamically Aaron Fay