You have to assign the left side of the comparison to a field name with annotate. At least I'm not aware of another way, except falling back to raw SQL.
Assuming VALUE in your example is just a variable:
This results in a query like this:
SELECT "T"."id", "T"."field", replace("T"."field", '-', ' ') AS "field_replaced" FROM "T" WHERE replace("T"."field", '-', ' ') = (replace('my_value', '-', ' '))
Hope that helps!
Daniel
On Thursday, August 24, 2017 at 10:44:40 PM UTC+2, Николай Инкогнито wrote:
On Thursday, August 24, 2017 at 10:44:40 PM UTC+2, Николай Инкогнито wrote:
SELECT * FROM T WHERE REPLACE(T.field, '-', ' ') = REPLACE(VALUE,'-', ' ')
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+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/82fde496-2523-4c03-bfa3-5771cb410485%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
No comments:
Post a Comment