django - Question mark in url pattern -
django 1.11.2
i need url pattern 2 cases:
- /blog/
- /blog/.json/
so, in case of json, i'll respond application/json content type.
this url pattern seems acceptable:
url(r'^blog/?(?p<json>\.json)?/$', blogfront.as_view()), at least, works. problem can't understand it.
the last ? match 0 or 1 repetitions of preceding re. it's ok. ? in middle capturing symbolic group.
what first question mark? mystery me. comment mean?
the first question mark makes preceeding / optional, making /blog.json/ valid. according question isn't want worth removing it
Comments
Post a Comment