Reverse for '' with arguments '()' and keyword arguments '{}' not found. 0 pattern(s) tried: []
我找到了我认为urls.py
中的错误 urlpatterns = patterns('',
url(r'^/?$', 'util.frontpage.frontpage', name='frontpage'),
(r'^schedule/', include('schedule.urls')),
(r'^user/', include('usermanagement.urls')),
(r'^group/', include('groupmanagement.urls')),
)
if settings.DEV_SERVER:
urlpatterns += staticfiles_urlpatterns()
urlpatterns += patterns('',(r'^login/$', 'django.contrib.auth.views.login'),
(r'^media/(?P<path>.*)$', 'django.views.static.serve',
{'document_root': settings.MEDIA_ROOT}),
)
因为它似乎没有找到匹配''的模式。
这是login.html模板:
{% extends "admin/base_site.html" %}
<link href="{{ STATIC_URL }}admin/css/login.css" rel="stylesheet">
{% block bodyclass %}login{% endblock %}
{% block content_title %}{% endblock %}
{% block breadcrumbs %}{% endblock %}
{% block content %}
{% if form.errors %}
<p class="errornote">Brukernavn/passord stemte ikke. Prøv igjen.</p>
{% endif %}
<div id="content-main">
<form action="{% url django.contrib.auth.views.login %}" method="post" id="login-form">
{% csrf_token %}
<div class="form-row">
{{ form.username.label_tag }}
{{ form.username }}
</div>
<div class="form-row">
{{ form.password.label_tag }}
{{ form.password }}
</div>
<div class="submit-row">
<input type="hidden" name="next" value="{{ next }}" />
<label> </label><input type="submit" value="Logg inn" />
</div>
</form>
<script type="text/javascript">
document.getElementById('id_username').focus()
</script>
</div>
{% endblock %}
我正在尝试将Django应用程序从1.4.15移植到1.7.3,到目前为止它一直在使用Okei,但我真的不知道如何修复此错误或urls.py
中的更改。这似乎是1.7.3如何解决网址的变化,任何帮助都深受赞赏。请询问您是否需要更多信息。
删除''
会导致
TypeError at /
can only concatenate tuple (not "str") to tuple
答案 0 :(得分:5)
{% url %}
现在的语法略有不同。你应该在网址名称周围加上引号:
{% url 'django.contrib.auth.views.login' %}