Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Filtering 'bundles' #24

Closed
yeago opened this issue Nov 24, 2009 · 4 comments
Closed

Filtering 'bundles' #24

yeago opened this issue Nov 24, 2009 · 4 comments

Comments

@yeago
Copy link

yeago commented Nov 24, 2009

There is no way currently to evaluate two filters together (AND vs OR on the relations queried):0

Given

class Organization(models.Model):
    name = models.CharField(..)

class Location(models.Model):
    organization = models.ForeignKey(Organization)
    zip_code = models.PositiveIntegerfield(...)
    open_saturday = models.BooleanField(...)

A django filter oriented around Organization but with fields for 'zip_code' and 'open_saturday' cannot give you all organization within a particular zip code who are also open saturday.

One possible approach would be to create a filter_together option for Meta, which would be a list of tuples of field name bundles. If there is a way to garner a Q object from a queryset, one could loop through these bundles compiling Q objects and then filter them together. If not, perhaps an as_q() method could be added to a filter which returns a Q object instead.

Like my other Issue in this realm, I really don't mind submitting code if a design decision favors things like this.

@yeago
Copy link
Author

yeago commented Nov 24, 2009

btw, its possible queryset.query.where.children could be munged into a Q.

@yeago
Copy link
Author

yeago commented Dec 9, 2009

This problem can be solved if extra(select={'the_related_field'... is used, because re-querying is not then necessary.

@yeago
Copy link
Author

yeago commented Oct 6, 2014

This is the same basic issue where filters force a join.

@yeago yeago closed this as completed Oct 6, 2014
@carltongibson
Copy link
Owner

OK — thanks — really helps to see where the work is needed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants