简体   繁体   English

NoReverseMatch at / accounts / signup / django-allauth错误

[英]NoReverseMatch at /accounts/signup/ django-allauth error

I have this code in my urls.py: 我在urls.py中有这个代码:

from django.conf.urls import url, include
from django.contrib import admin

urlpatterns = [
    url(r'^admin/', admin.site.urls),
    url(r'^accounts/', include('allauth.urls')),
    url(r'^profile/', include('userProfile.urls')),
]

and this is the userProfile.urls.py file: 这是userProfile.urls.py文件:

from django.conf.urls import url, include
from django.contrib import admin

from .views import (
    profile_user,
)

urlpatterns = [
    url(r'^(?P<id>[0-9]+)/profile/$', profile_user),
]

And I get this error NoReverseMatch at /accounts/signup. 我在/ accounts / signup收到此错误NoReverseMatch。 I read somewhere that the problem must be in the urls.py file, but I don't know why, if someone can help, it would be nice. 我在某处读到了问题必须在urls.py文件中,但我不知道为什么,如果有人可以提供帮助,那就太好了。 Everything worked fine last time I checked, and now something went wrong. 我上次检查时一切正常,现在出了问题。 Thank you. 谢谢。

I understand that the error might not be clear enough, so i copied the whole error from browser: 我理解错误可能不够清楚,所以我从浏览器复制了整个错误:

NoReverseMatch at /accounts/login/
Reverse for 'index' with arguments '()' and keyword arguments '{}' not found. 0 pattern(s) tried: []
Request Method: GET
Request URL:    http://127.0.0.1:8000/accounts/login/
Django Version: 1.9.5
Exception Type: NoReverseMatch
Exception Value:    
Reverse for 'index' with arguments '()' and keyword arguments '{}' not found. 0 pattern(s) tried: []
Exception Location: C:\Python27\lib\site-packages\django\core\urlresolvers.py in _reverse_with_prefix, line 508
Python Executable:  C:\Python27\python.exe
Python Version: 2.7.11
Python Path:    
['D:\\Programiranje\\Python\\Projekat ISA\\ProjekatRestorani',
 'C:\\WINDOWS\\SYSTEM32\\python27.zip',
 'C:\\Python27\\DLLs',
 'C:\\Python27\\lib',
 'C:\\Python27\\lib\\plat-win',
 'C:\\Python27\\lib\\lib-tk',
 'C:\\Python27',
 'C:\\Python27\\lib\\site-packages']
Server time:    Thu, 19 May 2016 12:03:20 +0000
Error during template rendering

In template C:\Python27\lib\site-packages\allauth\templates\account\login.html, error at line 14
Reverse for 'index' with arguments '()' and keyword arguments '{}' not found. 0 pattern(s) tried: []
4   {% load account socialaccount %}
5   
6   {% block head_title %}{% trans "Sign In" %}{% endblock %}
7   
8   {% block content %}
9   
10  <h1>{% trans "Sign In" %}</h1>
11  
12  {% get_providers as socialaccount_providers %}
13  
14  {% if socialaccount_providers %}
15  <p>{% blocktrans with site.name as site_name %}Please sign in with one
16  of your existing third party accounts. Or, <a href="{{ signup_url }}">sign up</a>
17  for a {{ site_name }} account and sign in below:{% endblocktrans %}</p>
18  
19  <div class="socialaccount_ballot">
20  
21    <ul class="socialaccount_providers">
22      {% include "socialaccount/snippets/provider_list.html" with process="login" %}
23    </ul>

But that is not my login.html code... This is what I have in my login.html file: 但那不是我的login.html代码......这就是我在login.html文件中的内容:

{% extends "base.html" %}
{% load i18n %}

{% block content %}
<form method="post" action=".">
  {% csrf_token %} 
  {{ form.as_p }}

  <input type="submit" value="{% trans 'Log in' %}" />
  <input type="hidden" name="next" value="{{ next }}" />
</form>

<p>{% trans "Forgot password" %}? <a href="{% url 'auth_password_reset' %}">{% trans "Reset it" %}</a>!</p>
<p>{% trans "Not member" %}? <a href="{% url 'registration_register' %}">{% trans "Register" %}</a>!</p>
{% endblock %}

So if I delete the files from my templates folder, and let him be empty, it works fine. 因此,如果我从我的模板文件夹中删除文件,并让他为空,它工作正常。 I hope I gave you some useful information now. 我希望我现在给你一些有用的信息。

The problem could be in your HTML. 问题可能在于您的HTML。 Try to namespace that url by adding name='profile'. 尝试通过添加name ='profile'来命名该URL。 Check in your HTML if you have something like 如果你有类似的话,请检查你的HTML

href="{% url 'YourApp:profile' %}"

You should check if your url's do have a ReverseMatch. 您应该检查您的网址是否有ReverseMatch。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM