jmcclell / django-bootstrap-pagination

Django template tag for rendering Page objects as Bootstrap pagination HTML
MIT License
212 stars 83 forks source link

read url_extra_kwargs from templatetag #10

Closed danodonovan closed 5 years ago

danodonovan commented 11 years ago

I was trying to use url_extra_kwargs in my project, and found that this was getting passed to BootstrapPaginationNode and BootstrapPagerNode as a string (keywords and args together). Not knowing a better way to pass a dict from template to django, I tweaked the code with

 import ast
 ast.literal_eval("{'my_kwarg':12}")

type munging. This was helpful to me, so I wondered if it might be helpful for you.

Great app btw!

jmcclell commented 11 years ago

This is a great idea, but it wouldn't be a backwards compatible change as others may be using this by passing a dictionary directly. It has been so long since I've worked on this that I forget how I originally was going about it. If you can update this to accept both cases I'll gladly merge it.

jmcclell commented 5 years ago

The preferred way is to pass the dict from the view as context. Adding ad hoc parsing of the dict from the template tag is going to be more error prone and harder to debug.