2👍
✅
Since you want to wirk with {whatever}
comming from /test/{whatever}
, you need to declare a variable in your url or pass {whatever}
via GET
variable.
Declaring a variable in url:
Change your url definition like this
...
url(r'^test/(?P<variable_name>\w+)/$', views.testUrl),
...
And catch it in the view:
def testUrl(request, variable_name):
# Now if you call '/test/hithere/'
# variable_name will take the value 'hithere'
# you could do -> parseIt = variable_name
...
Passing {whatever}
via GET
variable
You can always call you url like this:
mydomain.org/test/?var=hithere
And the in your view:
def testUrl(request):
parsetIt = request.GET.get('var')
...
Source:stackexchange.com