1

After the form is submitted a get request with parameters will be created, I was struggling with the regex in the urls.py I want to know the pattern for this Get request

/create-usecase/?usecase_name=test&category=1&sub_category=msameh&csrfmiddlewaretoken=m4UIwr0qsWuAwVJq7OCLt6KY8EnFrlFDNGJcTUicY2rUylMgFMzILElZaPDbNLtr

and how to get these values in the view function

M.Sameh
  • 85
  • 2
  • 8
  • Note that you don't need `{% csrf_token %}` in your form if you are making GET requests. – Alasdair May 16 '18 at 10:55
  • 1
    Duplicate of https://stackoverflow.com/questions/3711349/django-and-query-string-parameters – mic Jul 26 '19 at 02:36
  • Once you implemented the view which takes parameters from the GET, you can *add* a view with parameters in the URL that redirects to the query view. – dmcontador Dec 13 '22 at 09:23

1 Answers1

5

The query string is never part of the routing. The view at /create-usecase/ will need to inspect request.GET directly or otherwise and operate based on that.

Ignacio Vazquez-Abrams
  • 776,304
  • 153
  • 1,341
  • 1,358
  • so how to send the values of usecase_name, category and sub_category to another view function – M.Sameh May 16 '18 at 10:39
  • Get them from `request.GET`. – Ignacio Vazquez-Abrams May 16 '18 at 10:40
  • I am not sure how its going to work because in the urls.py I have a path of pattern 'create-usecase/' which fire up the function called create_usecase I want to take the values from the form in the create-user template and transfer it to another function which is questions but to do that i must use another url pattern which i don't know how to use request.get – M.Sameh May 16 '18 at 10:56