1

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 1

2

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

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

3 Comments

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'),
That's correct. I am assuming that Django 2.xx is installed.
Well, then this is the best solution.

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.