List Info

Thread: filter substitution




filter substitution
user name
2007-12-26 14:23:56
Dear Django-Users:

I'm trying to perform a filter substitution, whereby should
someone
try to fetch a QuerySet:

qs = project.models.Model.manager.filter(att1=val1,
att2=val2)

I would like to wire this internally so as to return:

qs = project.models.Model.manager.filter(att3=val3,
att4=val4)

instead, without the user being the wiser.  I have tried to
do this by
performing the substitution in the manager, by subclassing
the
get_query_set() function, but this apparently isn't the
place to do
it, as the Q objects are not set here (I introspect the
queryset
returned by a call to super, and would substitute the
queryset's
_filters' kwargs, but they don't exist yet).  I would
otherwise
subclass filter, but of course I want these changes applied
to any
query involving att1 and att2.  Anyone know where I need to
make this
change?

-Alex.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the
Google Groups "Django users" group.
To post to this group, send email to django-usersgooglegroups.com
To unsubscribe from this group, send email to
django-users-unsubscribegooglegroups.com
For more options, visit this group at htt
p://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---


[1]

about | contact  Other archives ( Real Estate discussion Medical topics )