agateblue / django-navutils

A lightweight package for handling menus and breadcrumbs in your django project
BSD 3-Clause "New" or "Revised" License
40 stars 12 forks source link

fix kwargs for reverse pattern_name #16

Open tboulogne opened 5 years ago

agateblue commented 5 years ago

Hi @tboulogne, I'd like to merge this, but I'm lacking some context. Can you please elaborate on the problem this solves? Thank you!

tboulogne commented 5 years ago

Hi @EliotBerriot,

Without self, kwargs is empty, and pattern with args never works.

Hope it help.

regards

agateblue commented 5 years ago

Isn't it possible to provide the kwargs when calling get_url ?

agateblue commented 5 years ago

E.g like that:

node = menu.Node('test', 'Test', pattern_name='category', reverse_kwargs=['slug'])
url = node.get_url(slug='test')
tboulogne commented 5 years ago

A best approach could be to use reverse syntax :

reverse('category', args=['slug'])

In you case :

node = menu.Node('test', 'Test', pattern_name=('category', ['slug'])

More logical.