views:

663

answers:

2

Caught an exception while rendering:
Reverse for 'products.views.'filter_by_led' with arguments '()' and keyword arguments '{}' not found.

I was able to successfully import products.views.filter_by_led from the shell and it worked so the path should be correct.

Here is the urls.py:
(r'^led-tv/$', filter_by_led ),

This is where the error is being generated:
href="{% url products.views.filter_by_led %}">

Which I can't understand because this works fine from the same file:
{% url products.views.lcd_screen_size screen_size=50 %}

Here is the function definition:
def filter_by_led(request):

I don't understand why Django would think that the function would not be able to find the Reverse for that function.

I deleted all the *.pyc files and restarted Apache.

What am I doing wrong?

+3  A: 

There are 3 things I can think of off the top of my head:

  1. Just used named urls, it's more robust and maintainable anyway
  2. Try using django.core.urlresolvers.reverse at the command line for a (possibly) better error

    >>> from django.core.urlresolvers import reverse
    >>> reverse('products.views.filter_by_led')
    
  3. Check to see if you have more than one url that points to that view

Jiaaro
+1 for named URLs
Chase Seibert
reverse seems to work fine from the shell:>>> from django.core.urlresolvers import reverse>>> reverse('products.views.filter_by_led')'/reviews/led/'
BryanWheelock
I also tried using names urls and I got the same type of error: Caught an exception while rendering: Reverse for 'ledtvfilter' with arguments '()' and keyword arguments '{}' not found.
BryanWheelock
if reverse worked in the shell then that probably isn't what's causing the error
Jiaaro
A: 

I don't think you need the trailing slash in the URL entry. Ie, put this instead:

(r'^led-tv$', filter_by_led ),

This is assuming you have trailing slashes enabled, which is the default.

Chase Seibert
it shouldn't matter, but if you want a trailing slash in the url, it should be there (All my `urls.py` files have the trailing slash)
Jiaaro