Reputation: 1431
I have designed the following url pattern
re_path(r'^api/refresh-token/(?P<token>[1-9]+\_[0-9a-f]{32}\Z)/$',refresh_token)
1_6506823466dc409a93b83b2c5f3b7cf2
matches the pattern [1-9]+\_[0-9a-f]{32}\Z
.
But when i hit the url it is not found.
System check identified no issues (0 silenced).
March 15, 2021 - 02:10:29
Django version 3.1.7, using settings 'tokenproject.settings'
Starting development server at http://127.0.0.1:8000/
Quit the server with CTRL-BREAK.
Not Found: /api/refresh-token/1_6506823466dc409a93b83b2c5f3b7cf2/
[15/Mar/2021 02:10:32] "PUT /api/refresh-token/1_6506823466dc409a93b83b2c5f3b7cf2/ HTTP/1.1" 404 3279
Upvotes: 1
Views: 55
Reputation: 476604
The \Z
asserts the end of the string, or before the line terminator, but there is still content to match: the slash at the end, so the \Z
makes it impossible to satisfy any string at all.
You do not need to use \Z
at all here, since there is no multi-line, and $
already matches the end of the line.
You this can implement this with:
re_path(r'^api/refresh-token/(?P<token>[1-9]+\_[0-9a-f]{32})/$', refresh_token)
Upvotes: 2