Задать вопрос

Тел: +7 965 3737 888

448

Просмотров

2

Ответов

One step up from __icontains

The REGEX and IREGEX operators were added in Django 1.0 and I'm sure you can think of fancier ways of doing word delimiting and things like that but this was all I needed to make a user-friendly autocomplete search function.

Вопрос полезен? Да0/Нет0
file_3744.py(519.0б)
None

Ответы (2):

Ответpeterbe:10.09.2010
Ответ полезен? Да0/Нет0

Using the \b can be troubling. Remember the regular expression has to be turned into SQL.

In fact I think \b works on SQLite but not on PostgreSQL.

Ответaparo:09.09.2010
Ответ полезен? Да0/Нет0

I sugget you to use the \b boundary:

Client.objects.filter(name__iregex=r"\bart")

so you can also match "(artist", "{article", ...