Skip to content

Instantly share code, notes, and snippets.

@lukeman
Created May 2, 2010 02:14
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lukeman/386835 to your computer and use it in GitHub Desktop.
Save lukeman/386835 to your computer and use it in GitHub Desktop.
Example of using django-sorting, django-filter and django-pagination together
{% load pagination_tags %}
{% load sorting_tags %}
{% block body %}
{% autosort filter.qs as sorted_objects %}
{% autopaginate sorted_objects 10 as object_list %}
{% for object in object_list %}
{{ object }}
{% endfor %}
{% paginate %}
{% endblock %}
{% block sidebar %}
<div class="filter">
<h2>Sort by</h2>
<ul>
<li>{% anchor firstfield "First Field" %}</li>
<li>{% anchor otherfield "Other Field" %}</li>
</ul>
<form action="" method="get" class="filter">
{{ filter.form.as_p }}
</form>
</div>
{% endblock %}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment