views:

1769

answers:

1

I have a line in a Django form :

{% for aa in my_array %}

which seems to be triggering this error :

Template error

Caught an exception while rendering: Reverse for 'dev_env.profiles.views.viewPlan' with arguments '('',)' and keyword arguments '{}' not found.

What does this error message really mean?

I suspect that either the line is correct, but the error message is wrong. Or the error is real but this line is a red-herring.

What on earth should I be looking for?

Update : Paulo sorted this, below.

In fact, I had a {% url viewPlan planId %} a couple of lines away (so the reported error line was wrong), but the error was triggered because planId was empty in this case.

+4  A: 

Do you have a view named viewPlan with which you do something like this in a template:

{% url viewPlan %}

or something like this in a view:

reverse('viewPlan')

If you do that and you do not have a line that looks like this:

url(r'^whatever/url/$', 'dev_env.profiles.views.viewPlan', name="viewPlan"),

...in your url configuration I would imagine that's the error you're getting. Alternatively, and more likely, you are probably capturing a value (maybe id or something) in the viewPlan URL but are not passing an argument when reversing the url. So if you are capturing any values in the regex, like this:

url(r'^plans/(\d+)$', 'dev_env.profiles.views.viewPlan', name="viewPlan"),

You need to call it like this:

{% url viewPlan 15 %}

Or like this:

reverse('viewPlan', args=[15]);

Where 15 is obviously whatever the captured value is expecting.

Paolo Bergantino
thank you, that took me in the right direction. It was actually just the argument I was passing in the {% url was empty in this context.Cheers
interstar
You would also get the same error if you replace 'viewPlan' with 'viewPan'
Casebash