Search code examples
djangodjango-templatesdjango-pagination

Different template for django-pagination


I have just started playing around with django-pagination, which is included in some other 3rd-party app I am using for one of my projects.

Does anyone know if it's possible to replace the pagination.html template inside django-pagination with a custom version without having to hack the actual app? There is nothing mentioned in the docs and pagaination.html is hardcoded inside the templatetag (paginate()). I was wondering if there is a mechanism that allows overriding the template that was set via

register.inclusion_tag('pagination/pagination.html', takes_context=True)(
paginate)

from within my own app?


Solution

  • You can simply create pagination/pagination.html within the template folder of your project and it will take precedence over the pagination app's pagination.html. So simply copy and paste the code from the pagination app's version into your version and edit to your hearts content

    The template tag you mention simply renders a context against the template, so you don't need to do any hacking with it to change the layout/appearance/template.