与'*'相反,参数'()'和关键字参数'{}'未找到 [英] Reverse for '*' with arguments '()' and keyword arguments '{}' not found

查看:105
本文介绍了与'*'相反,参数'()'和关键字参数'{}'未找到的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


使用参数'()'和$ 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。



我做错了什么?

解决方案

有三件事我可以想到我的头顶:


  1. 刚刚使用命名urls ,它更加强大和可维护无论如何

  2. 尝试使用 django.core .urlresolvers.reverse 在命令行为a (可能)更好的错误

     >>>来自django.core.urlresolvers import reverse 
    >>>> reverse('products.views.filter_by_led')


  3. 查看是否有超过一个指向该视图的网址



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:

  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

这篇关于与'*'相反,参数'()'和关键字参数'{}'未找到的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆