Django throwing error with '/' in url -
i have urls.py in django app follows:
url(r'^myurl/(?p<pid>.*)/(?p<qid>.*)/(?p<trantype>.*)$', views.myview.as_view(), name='myurl'),
here trantype
parameter in url can sometime have '/' data gets. when such scenario occurs, django throws me error number of parameters being exceeded. how can make trantype
parameter take '/' well?
i think error message misleading here.
rather exceeding amount of parameters expect not find enough parameters because .* greedy,that means try match as possible, pid match until last occuring backslash. i'm not sure why work @ all.
if qid , pid parameters cannot contain slashes advised restrict corresponding capturegroup \w+
.
try pattern:
url(r'^myurl/(?p<pid>\w+)/(?p<qid>\w+)/(?p<trantype>.*)$', views.myview.as_view(), name='myurl'),
also try make capture groups lazy, if \w doesn't cut it:
url(r'^myurl/(?p<pid>.*?)/(?p<qid>.*?)/(?p<trantype>.*)$', views.myview.as_view(), name='myurl'),
i use slashes ( base64 encoded strings ) in endpoints , have not had issues them.
Comments
Post a Comment