Please how can I pass a string arguments to django path
path('mysite/?$', search, name='search')
instead of the ?$ I want to pass the argument that the get method has ! how can I do that ??
1 Answer
I guess you need something like that:
path('mysite/<int:number>', views.search, name='search'),
or
path('mysite/<str:search>', views.search, name='search'),
in you urls.py
Also don't forget to add an argument to the search in the views.py
3 Comments
Anlis
One correction: this code will work only for django version > 2.0, otherwise you need to use regular expression. The simplest one (but not the best) is something like path('mysite/?.*$', views.search, name='search'),
Daedalus
That's correct. I am assuming that Django 2.xx is installed.
Anlis
Well, then this is the best solution.