与'*'相反,参数'()'和关键字参数'{}'未找到 [英] Reverse for '*' with arguments '()' and keyword arguments '{}' not found
问题描述
使用参数'()'和$ b反转'products.views.'filter_by_led' $ b关键字参数'{}'未找到。
我能够成功导入 products.views。 filter_by_led
从shell,它的工作,所以路径应该是正确的。
这是urls.py:
(r'^ led-tv / $',filter_by_led),
这是正在生成错误的地方:
href ={%url products .views.filter_by_led%}>
我不能理解,因为这个文件可以正常工作:
{%url products.views.lcd_screen_size screen_size = 50%}
这是函数定义:
def filter_by_led(request):
我不明白为什么Django会认为该功能将无法找到该功能的Reverse。 / p>
我删除了所有的 *。pyc
文件并重新启动Apache。
我做错了什么?
有三件事我可以想到我的头顶:
- 刚刚使用命名urls ,它更加强大和可维护无论如何
-
尝试使用
django.core .urlresolvers.reverse
在命令行为a (可能)更好的错误>>>来自django.core.urlresolvers import reverse
>>>> reverse('products.views.filter_by_led')
-
查看是否有超过一个指向该视图的网址
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?
There are 3 things I can think of off the top of my head:
- Just used named urls, it's more robust and maintainable anyway
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')
Check to see if you have more than one url that points to that view
这篇关于与'*'相反,参数'()'和关键字参数'{}'未找到的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!