Queryset Filters

30 views
Skip to first unread message

Jill Green

unread,
Apr 9, 2014, 1:33:16 AM4/9/14
to django...@googlegroups.com
I apologize if this question has already been asked and answered. I want to know if it's possible to filter out query sets without doing lazy queries or hitting the database again. Basically I have this query:

qs= self.filter(a months worth of data)

Now if I evaluate this query by doing this:

if qs:
qs=qs.filter(a weeks worth of data inside that month)

Why does the second filter not just search the objects inside that first queryset? And is there a way to do just that? Essentially I'm trying to avoid hitting the database again.
I'm using Django 1.3.4 with MySQL if that matters.

Thanks in advance for any replies.

JG

Sent from my iPhone

Anssi Kääriäinen

unread,
Apr 9, 2014, 2:27:33 AM4/9/14
to django...@googlegroups.com
No, there is no way to do what you want. All filters are implemented as filters in the DB, Django doesn't know how to execute them in Python. There was some effort to implement filters also in Python, but there hasn't been any activity on this recently.

The only way to do this currently is to implement the filtering logic in Python yourself.

 - Anssi

Jill Green

unread,
Apr 9, 2014, 2:30:18 AM4/9/14
to django...@googlegroups.com
Thank you for the response.  I feared the answered would be no but I wanted to be sure.

Sent from my iPhone
--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users...@googlegroups.com.
To post to this group, send email to django...@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/d6836bf3-39f4-41bf-a5c5-bd6ffb63ca52%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages