3

right now I have a view to show info about some tickets and I'm trying to add a functionality to filter those tickets.

Say I will have 4 filters:

  • Date
  • Owner
  • Category
  • Status

Category Status

I want to give the option to use some of those filters, all or none, the thing is I'm kinda lost in how can I make it work in the urls. So far I found that you can add some optional arguments but they appear in some sort of succession like:

/May/Jack/Gas/Accepted

But if I only select 2 filters like /Jack/Accepted/ it grabs the filters incorrectly.

Is there a way I can achieve this? Or some other method I can use instead of this. Ty

1
  • what have you tried so far. Post your urls.py and views.py Commented Jul 4, 2017 at 13:21

1 Answer 1

2

Don't try and do this with URL arguments. Instead, use querystring arguments. The URL should be in the form:

my_path/?date=May&owner=Jack&category=Gas&status=accepted

and the URL pattern is just:

url(r'^my_path/$', views.my_view, 'my_url'),

and in the view you can access request.GET['date'] etc.

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

Comments

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.