Reputation: 17876
I have three url pattern match to the same url name
url(r'^report/newreport/(?P<number>\w+)/$', 'report.views.newreport',name='report_newreport'),
url(r'^report/newreport/(?P<number>\w+)/(?P<edit>\w+)/$', 'report.views.newreport',name='report_newreport'),
url(r'^report/newreport/$', 'report.views.newreport',name='report_newreport'),
When I tried to use 'url' to get full url like this
<td><a href='{% url report_newreport report.applicationnumber %} ' target='_blank' >{{task.applicationnumber}}</a> <br/>
I got an error
Caught NoReverseMatch while rendering: Reverse for 'report_newreport' with arguments '('',)' and keyword arguments '{}' not found.
Is that because I matched three urls to one url name? I think this shoudl be fixed by matching these three patterns to three different url names. Is that other way I can fix this error
Thanks
Upvotes: 1
Views: 1453
Reputation: 4047
I think the issue is with the fact that report.applicationnumber
is not generating a value: with arguments '('',)'
in the error message indicates that report.applicationnumber
's value is empty in which case the url
tag attempts to match the URL pattern ^report/newreport//$
which does not exist in your URL list.
Upvotes: 1