I
I
Ivan2015-07-30 10:07:48
Django
Ivan, 2015-07-30 10:07:48

What is the best way to filter by the first character?

Good day, gentlemen. Please advise how best to implement filtering by the first letter.
The essence of the problem: there is an alphabet, and there is a table in which definitions are written. When you click on a letter of the alphabet, definitions that begin with that letter are displayed.
I think to solve this problem in this way. Attach a URL to each letter, for example, when you click on the letter "A", a link like: was formed http://example.com/a/,
in urls.py it will be:

url(r'^(?P<symbol>[а-я]{1})/$', TestView.as_view(), name='test'),

and then catch this symbol in the view and do Test.objects.filter(name__startswith='symbol').
Maybe someone knows how to do it better? Many thanks in advance.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
sim3x, 2015-07-30
@ATNC

It's ok , just check how junga will react to https://en.wikipedia.org/wiki/Punycode

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question