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

大城市里の小女人 提交于 2020-01-17 14:04:13

问题


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.

回答1:


{% 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.



来源:https://stackoverflow.com/questions/14452700/i-getting-a-reverse-for-views-mainpage-with-arguments-and-keyword-argume

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!