Reputation: 5162
Supposing that I have something like that in my urls.py
:
url(r'^task/(?P<pk>[0-9]+)/', taskview, name='taskview')
How can django help me extract '10' (or {"pk": 10}
) from reading any matching URL string like:
/task/10/
/task/10///
/task/10/dddd/dddd/dddwwwww/wwwwq/qqqqqqw/qwead/?adawd=awodawdoij
?
(FYI when I say "reading any URL string" I mean that I am not receiving a request on those urls, but rather that I have such a string in my code on which I have to perform the aforementioned keyword extraction)
Upvotes: 2
Views: 1590
Reputation: 5162
Just figured it out:
from django.urls import resolve
resolve(url).kwargs
Upvotes: 4