#28527 closed Uncategorized (invalid)
How rewrite query in Django ORM?
Reported by: | Nikolas | Owned by: | nobody |
---|---|---|---|
Component: | Database layer (models, ORM) | Version: | 1.11 |
Severity: | Normal | Keywords: | |
Cc: | Triage Stage: | Unreviewed | |
Has patch: | no | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
has any way to rewrite in Django ORM?
SELECT * FROM T
WHERE REPLACE(T.field, '-', ' ') = REPLACE(VALUE,'-', ' ')
its possible?
can add this feature or add sample to Docs?
Change History (2)
comment:1 by , 7 years ago
Resolution: | → invalid |
---|---|
Status: | new → closed |
comment:2 by , 7 years ago
i try
obs = Goods.objects\ .annotate(data2=Func( # F('data'), F('data'), Value("'-'"), Value("' '"), function='replace', ))\ .filter( Q(data__contains="Andrew") | Q( data2=Func( F('data'), Value("'-'"), Value("' '"), function='replace', ), ))
but cant compare to function (not field), this is not documented, can litle help please?
and i think must be more examples in Docs, complex and big examples, very need.
Thanks for great soft!
Version 0, edited 7 years ago by (next)
Note:
See TracTickets
for help on using tickets.
Hello Nikolas,
It should be a matter of using
annotate()
withFunc(F('field'), function='REPLACE'))
expressions but I don't think we should be documenting every single use ofFunc
.I suggest you take a look at how you can get support if the documentation isn't enough to help you solve your issue.