Reputation: 110277
In the following url:
(r'^videos/view/(?P<video_id>[^/]+)/$'
r'
mean/do??P
mean/do?<video_id>
escaped by the regex?In other words, how is the above different than:
'^/videos/view/[^/]+/$'
Upvotes: 2
Views: 252
Reputation: 28846
r''
marks a raw string, so that you don't have to double-escape backslashes. In this case, it's not necessary because there aren't any, but a lot of people always do it for regexes anyway.
(?P<video_id>[^/]+)
is a Python extension to regexes that "names" that capture group video_id
. In Django, this means that the match is sent to the view as a keyword argument video_id
; if you did view/([^/]+)/$
, it would be sent as the first positional argument. In your example, though, there are no parens at all, meaning that the view wouldn't get any arguments!
Upvotes: 5