django-pure-pagination icon indicating copy to clipboard operation
django-pure-pagination copied to clipboard

Added setting to allow change the template when pagination is rendered

Open grouser opened this issue 8 years ago • 7 comments

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).

grouser avatar Mar 21 '16 13:03 grouser

+1 for this, but pagination-bootstrap.html is not fully compatible with pagination.html. For example pagination.html does not contain variable verbose.

lampslave avatar Mar 23 '16 03:03 lampslave

Yes, it is true.

I have removed the verbose conditionals alongside the is_paginated block to make it compatible with normal views as well.

image

grouser avatar Mar 23 '16 10:03 grouser

is_paginated is built-in varialbe.

lampslave avatar Mar 23 '16 11:03 lampslave

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.

grouser avatar Mar 23 '16 12:03 grouser

I fear this might break CBV templates.

lampslave avatar Mar 23 '16 12:03 lampslave

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.

grouser avatar Mar 23 '16 13:03 grouser

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?

UncleVasya avatar Apr 08 '16 17:04 UncleVasya