Welcome to django-bootstrap-pagination
It is a fork from ericflo/django-pagination to fit bootstrap pagination layout
Installing
Clone the repo
$ git clone git://github.com/tgdn/django-bootstrap-pagination.git
and install
$ cd django-bootstrap-pagination/
$ python setup.py install
You may need to have root access, then use sudo python setup.py install
instead
In your settings.py add to your INSTALLED_APPS
bootstrap_pagination
INSTALLED_APPS = (
...
'bootstrap_pagination',
...
)
and to your MIDDLEWARE_CLASSES
add 'bootstrap_pagination.middleware.PaginationMiddleware'
MIDDLEWARE_CLASSES = (
'django.middleware.common.CommonMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
...
'bootstrap_pagination.middleware.PaginationMiddleware',
)
How to use
In your view use
def view(request, query):
users = User.objects.filter(first_name=query)
return render_to_response("template.html", { 'users':users }, context_instance=RequestContext(request))
... or whatever you want
In your template use
<!-- load tags and filters -->
{% load pagination_tags %}
<div>
<!--
users: the list to paginate
20: results per page
-->
{% autopaginate users 20 %}
<ul>
{% for user in users %}
<li>{{ user.username }}</li>
{% empty %}
No results...
{% endfor %}
</ul>
<!-- navigation -->
{% paginate %}
</div>
Then run the server !
How it looks like?
Authors and Contributors
Forked from (@ericflo)'s django-pagination