使用参数“()"和关键字参数“{}"未找到的“*"反转 [英] Reverse for '*' with arguments '()' and keyword arguments '{}' not found
问题描述
渲染时发现异常:
<块引用>'products.views.'filter_by_led' 与参数 '()' 和未找到关键字参数{}".
我能够从 shell 成功导入 products.views.filter_by_led
并且它工作正常,所以路径应该是正确的.
这里是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.
我删除了所有 *.pyc
文件并重新启动了 Apache.
我做错了什么?
我能想到 3 件事:
- 刚刚使用了命名网址,无论如何它更健壮和可维护
尝试在命令行中使用
<预><代码>>>>从 django.core.urlresolvers 导入反向>>>反向('products.views.filter_by_led')django.core.urlresolvers.reverse
以获得(可能)更好的错误检查您是否有多个指向该视图的网址
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屋!