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

RFE: Lookup two field values #43

Open
vkrizan opened this issue Apr 29, 2019 · 3 comments
Open

RFE: Lookup two field values #43

vkrizan opened this issue Apr 29, 2019 · 3 comments

Comments

@vkrizan
Copy link
Contributor

vkrizan commented Apr 29, 2019

(Feature Request)

Hello,

Would it be possible to extend the query language to support lookup by other fields value?

For example:

name ~ title

would translate to

Q(name__icontains=F('title'))

The suggestions can also offer the field name in the context where a value is expected.

Thank you for consideration.

@stebunovd
Copy link
Member

hey Viliam,

thank you for the idea, sounds interesting. I wonder if references to other fields alone would feel like a self-sufficient feature. I guess that when we use F() in Django, it would be quite often used as a part of an expression, for example:

Q(date_published__lte=F('date_created') + timedelta(days=1))

If we start thinking about it this way, taking into account complex expressions and functions, the scope of the feature starts to look huge. Of course, this is not always the case, and sometimes F() is used alone. I don't have any stats though.

On one hand, I can understand the need for referencing other fields. On the other hand, I'm afraid that it may be a path down the rabbit hole and may add too much complexity to the library. What do you think?

thanks,

Denis

@vkrizan
Copy link
Contributor Author

vkrizan commented May 7, 2019

Hello Denis,

Your points are very valid. We had a use-case when two dates have been compared, if one precedes the other. I understand that this might not be a very common case, and would lead to more complex structures, as you mentioned.

Unless anyone would have another use-case, we can close this issue.

@violuke
Copy link
Contributor

violuke commented May 10, 2024

We'd love to see this. We were also looking for date related comparison - we have an invoice model and were looking for invoices where the invoice_date is different from the delivery_date 👍

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

3 participants