1

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

icn
  • 17,126
  • 39
  • 105
  • 141
  • 1
    Why do you need to have multiple views with the same name? Have you tried giving them different names? – perelman Feb 13 '12 at 05:59
  • 1
    Also, assuming "ccicreport" is supposed to be "report" like the others, you could possibly merge them into a single regex following the example of [Making a Regex Django URL Token Optional](http://stackoverflow.com/q/2325433). – perelman Feb 13 '12 at 06:01
  • @perelman Yes, it was a typo :), updated. – icn Feb 13 '12 at 06:04

1 Answers1

1

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.

philofinfinitejest
  • 3,987
  • 1
  • 24
  • 22