#26641 closed Uncategorized (invalid)
Unable to concatenate 2 fields when filtering
Reported by: | FoxPotato | Owned by: | nobody |
---|---|---|---|
Component: | Database layer (models, ORM) | Version: | 1.9 |
Severity: | Normal | Keywords: | QuerySet.extra |
Cc: | foxpotato5@… | Triage Stage: | Unreviewed |
Has patch: | no | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
The docs said I should file a ticket when using the extra API.
I just need a way to use the icontains field lookup on 2 fields at once, for example the full name (first_name + last_name) of a user.
I managed it using the extra API like this:
User.objects.extra(where=['upper(concat(first_name, " ", last_name)) LIKE upper(%s)'], params=[query])
Change History (1)
comment:1 by , 9 years ago
Resolution: | → invalid |
---|---|
Status: | new → closed |
Version 0, edited 9 years ago by (next)
Note:
See TracTickets
for help on using tickets.
You should be able to use the Concat functions for this purpose:
Or simply using
Q
objects: