2

I have urls like:

url(r'^utilisateurs/$', view = list_users, name='list_users'),
url(r'^utilisateurs/(?P<userType>[\w-]+)/$', view = list_users, name='list_users_by_type'),
url(r'^utilisateurs/order_by/(?P<orderBy>[\w-]+)/$', view = list_users, name='list_users_order_by'),
url(r'^utilisateurs/(?P<userType>[\w-]+)/order_by/(?P<orderBy>[\w-]+)/$', view = list_users, name='list_users_by_type_order_by'),

I am trying to put a order_by tab in my template like below:

<ul id='menu-order-by'>
            <li><a href='{{ request.get_full_path }}order_by/title/'>Title</a></li>
</ul>

As you can see i am adding order_by parameter manually because the list can already be filtered . And the order_by menu items must order according to the current filtered list.

Can there be a better way to accomplist this task?

1 Answer 1

1

As I understand, you need some thing like {% url %} tag: https://docs.djangoproject.com/en/dev/ref/templates/builtins/#url There you can provide parameters into this tag, like {% url 'list_users_order_by' [[WHATEVER YOU PASS]] %}. If in WHATEVER YOU PASS you provide 'title', it's will be what you need.

Sign up to request clarification or add additional context in comments.

1 Comment

I tried the ? query parameters with request.sessions but will try your advice too thanks. For now I have changed the links hrefs to --> {{ request.path }}?order=title

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.