kartikq
kartikq

Reputation: 651

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(request,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>

Upvotes: 1

Views: 491

Answers (2)

buckley
buckley

Reputation: 2110

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.

Upvotes: 1

Daniel Roseman
Daniel Roseman

Reputation: 599610

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.

Upvotes: 1

Related Questions