NoReverseMatch error in django app
I am receiving this error in one of my templates and cant seem to figure out what's wrong.
`NoReverseMatch: Reverse for 'getimagefile'
with arguments '(12L, 'afN9LRzESh4I9CGe6tFVoA==\n')' and
keyword arguments '{}' not found.
My urls.py contains:
urlpatterns = patterns('myproj.myapp.views',
url(r'^getimage/(?P<extractedcontent_id>\d+)/(?P<encpw>.*)/$','getimagecontent',name='getimagefile'),
)
My views.py contains:
def getimagecontent(req开发者_运维知识库uest,extractedcontent_id,encpw):
........
And finally my template that's giving me the error contains the following line:
<li class="active"><img src="{% url getimagefile img,encpw %}" title=""/></li>
Your encpw variable ends in a newline character, by default the . regular expression character does not capture these. Try altering your regex so the DOTALL flag is turned on, which will match for newline characters.
url(r'(?s)^getimage/(?P<extractedcontent_id>\d+)/(?P<encpw>.*)/$','getimagecontent',name='getimagefile'),
Notice the (?s)
at the very beginning this will turn the DOTALL flag on.
You don't show where encpw
comes from, but it appears to have a newline character (\n
) at the end, which won't match the url regex.
精彩评论