Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added setting to allow change the template when pagination is rendered #35

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

grouser
Copy link

@grouser grouser commented Mar 21, 2016

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

@lampslave
Copy link
Contributor

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

@grouser
Copy link
Author

grouser commented Mar 23, 2016

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

@lampslave
Copy link
Contributor

is_paginated is built-in varialbe.

@grouser
Copy link
Author

grouser commented Mar 23, 2016

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.

@lampslave
Copy link
Contributor

I fear this might break CBV templates.

@grouser
Copy link
Author

grouser commented Mar 23, 2016

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.

@UncleVasya
Copy link

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants