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

Тел: +7 965 3737 888

519

Просмотров

0

Ответов

Filter by first letter inclusion tag

<p>My first snippet ;]</p>
<p>It's a simple inclusion tag for filtering a list of objects by a first letter using <a href="http://github.com/alex/django-filter">django-filter</a></p>
<p>after having this "installed" you can use it in your template like this:</p>
{% load my_tags %}
&lt;div class="letter_filter"&gt;
     Filter by first letter: {% letters_filter "MyNiceModel" %}
&lt;/div&gt;

<p>for information how to use django-filter in your view go to <a href="http://github.com/alex/django-filter/blob/master/docs/usage.txt">docs</a></p>
<p>you should probably cache this inclusion tag since it makes 45 queries to the db (.count() &gt; 0)</p>
<p>Enjoy and improve ;]</p>
<p>PS. some parts of this code are in Polish</p>

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