Generate Dynamic URL based on User Selection in Django

Viewed 17

I am very new to Django and would appreciate any help.

Scenario: User selects (A, B, C or D) from a dropdown menu (using forms.Select widget in Django) and clicks a Submit button. On the button click:

  1. Based on user's selection, dynamically generate a URL e.g. localhost/D
  2. I plan to capture the selection D in the URL using regular expression (r'^(\w+)/$') and generate the corresponding view.

Where am I stuck: I can't seem to find a way to dynamically generate the URL and redirect to it via button click. Since the button is HTML tag and will have href to the dynamically generated URL, I don't know how to achieve this.

0 Answers
Related