Opened 9 years ago
Closed 9 years ago
#27429 closed New feature (duplicate)
had to use QuerySet.extra to do WHERE LIKE with arbitrary amount / placement of wildcard characters
| Reported by: | Lance Robertson | Owned by: | nobody |
|---|---|---|---|
| Component: | Database layer (models, ORM) | Version: | dev |
| Severity: | Normal | Keywords: | QuerySet.extra |
| Cc: | Triage Stage: | Unreviewed | |
| Has patch: | no | Needs documentation: | no |
| Needs tests: | no | Patch needs improvement: | no |
| Easy pickings: | no | UI/UX: | no |
Description (last modified by )
My use case is that I'm trying to find phonetic patterns that rhyme using a database I built from the pronunciation dictionary CMUdict
For example:
Pronunciation.objects.extra(where=["code LIKE '%% - %%__1 - S T __0 D'"])
I want to be able to filter with % and _ wildcards in arbitrary amounts and places in the search string beyond just contains, startswith, and endswith, and the only way I could figure out how to do it is either to use a raw query or .extra - if .extra goes away I hope filter will support this behavior!
Change History (2)
comment:1 by , 9 years ago
| Description: | modified (diff) |
|---|
comment:2 by , 9 years ago
| Component: | Uncategorized → Database layer (models, ORM) |
|---|---|
| Resolution: | → duplicate |
| Status: | new → closed |
| Type: | Uncategorized → New feature |
| Version: | 1.10 → master |
Note:
See TracTickets
for help on using tickets.
It was decided that we were not going to add
likeandilikelookups in #17473.Now that custom lookups are available you can define your own
LIKEimplementation as follow:And use like that