我得到一个'反向''views.mainPage',带有'()'和关键字参数'{}'找不到。 [英] I getting a 'Reverse for 'views.mainPage' with arguments '()' and keyword arguments '{}' not found.'

查看:108
本文介绍了我得到一个'反向''views.mainPage',带有'()'和关键字参数'{}'找不到。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



mainPage方法在/ django_crm / crm / views.py

  @login_required 
def mainPage(request):
variables = RequestContext (请求,{
'user':request.user,
})

返回render_to_response('mainPage.html',变量)

和/django_crm/django_crm/templates/mainPage.html

 code>< HTML> 
< head>
< title> test< / title>
< / head>
< body>
{%url'crm.views.mainPage'%}
< / body>
< / html>

错误...

 反向为''crm.views.mainPage''与参数'()'和关键字参数'{}'找不到。 


解决方案

{%load url from未来%} 如果您使用django< 1.5





从url标签中移除引号。


在Django 1.5中更改:第一个不被引用的参数,
与其他模板标签不一致。由于Django 1.5,它根据通常的规则评估
:它可以是一个引用的字符串
或将在上下文中查找的变量。



I getting a 'Reverse for 'views.mainPage' with arguments '()' and keyword arguments '{}' not found.'

mainPage method in /django_crm/crm/views.py

@login_required
def mainPage(request):
    variables = RequestContext(request, {
            'user': request.user,
            })  

    return render_to_response('mainPage.html', variables)

and /django_crm/django_crm/templates/mainPage.html

<html>
    <head>
        <title>test</title>
    </head>
    <body>
        {% url 'crm.views.mainPage' %}
    </body>
</html>

Error...

Reverse for ''crm.views.mainPage'' with arguments '()' and keyword arguments '{}' not found.

解决方案

{% load url from future %} if you are using django < 1.5

Or

Remove quotes from url tag.

Changed in Django 1.5: The first parameter used not to be quoted, which was inconsistent with other template tags. Since Django 1.5, it is evaluated according to the usual rules: it can be a quoted string or a variable that will be looked up in the context.

这篇关于我得到一个'反向''views.mainPage',带有'()'和关键字参数'{}'找不到。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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