django-pure-pagination
django-pure-pagination copied to clipboard
Added setting to allow change the template when pagination is rendered
Sometimes you want to render a different template like pure_pagination/pagination-bootstrap.html, which is included in this project. Adding a TEMPLATE setting will be enough to do it, using as default the existing one (pure_pagination/pagination.html).
+1 for this, but pagination-bootstrap.html
is not fully compatible with pagination.html
. For example pagination.html
does not contain variable verbose
.
Yes, it is true.
I have removed the verbose conditionals alongside the is_paginated block to make it compatible with normal views as well.
is_paginated
is built-in varialbe.
That's for the Class-based views. If you use a normal Django view, you don't have that variable in your template. I had to remove it to get the pagination.
I fear this might break CBV templates.
it won't break it, even the default template (pagination.html) doesn't have it. The idea to have a template setting is to be able to set your own template. You are free to use an existing or your own template. The template (pagination-bootstrap.html) was included in this project as well. I have added the template pagination-bootstrap-class-based-view.html to use it in a CBV so that you can choose the one that suits you better.
Let's say you have 'my_pagination.html' in your project.
In your normal page template you can replace
{{ page.render }}
with
{% include 'my_pagination.html' with page_obj=page %}
And no settings required.
Also, unlike with settings, you don't need to restart server if you switch between my_pagination.html
and another_pagination.html
.
Or am I missing the point of this change?