Я пытаюсь использовать вход через Facebook с Python Social Auth, но получаю следующее сообщение, когда я вхожу в систему, и facebook возвращается на мой сайт:
NoReverseMatch at /
Reverse for 'begin' with arguments '(u'facebook',)' and keyword arguments '{}' not found. 1 pattern(s) tried: [u'$login/(?P<backend>[^/]+)/$']
Вот мои взгляды:
def home(request):
"""Home view, displays login mechanism"""
if request.user.is_authenticated():
return redirect('done')
return render_to_response('home.html', {
'plus_id': getattr(settings, 'SOCIAL_AUTH_FACEBOOK_KEY', None)
}, RequestContext(request))
@login_required
def done(request):
"""Login complete view, displays user data"""
scope = ' '.join(FacebookAuth.DEFAULT_SCOPE)
return render_to_response('done.html', {
'user': request.user,
#'plus_id': getattr(settings, 'SOCIAL_AUTH_GOOGLE_PLUS_KEY', None),
#'plus_scope': scope
}, RequestContext(request))
Это вся трассировка:
Environment:
Request Method: GET
Request URL: http://127.0.0.1:8000/
Django Version: 1.6.1
Python Version: 2.7.5
Installed Applications:
('django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'reviews',
'south',
'taggit',
'register',
'endless_pagination',
'social.apps.django_app.default')
Installed Middleware:
('django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware')
Traceback:
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/core/handlers/base.py" in get_response
114. response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "/Users/filipeferminiano/Documents/django/tests/consumidor/reviews/views.py" in home
19. return redirect('done')
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/shortcuts/__init__.py" in redirect
78. return redirect_class(resolve_url(to, *args, **kwargs))
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/shortcuts/__init__.py" in resolve_url
151. return urlresolvers.reverse(to, args=args, kwargs=kwargs)
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/core/urlresolvers.py" in reverse
509. return iri_to_uri(resolver._reverse_with_prefix(view, prefix, *args, **kwargs))
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/core/urlresolvers.py" in _reverse_with_prefix
429. (lookup_view_s, args, kwargs, len(patterns), patterns))
Exception Type: NoReverseMatch at /
Exception Value: Reverse for 'done' with arguments '()' and keyword arguments '{}' not found. 0 pattern(s) tried: []
Это мой urls.py
urlpatterns = patterns("",
url(r'^$', 'reviews.views.home'),
url(r"^admin/", include(admin.site.urls)),
#registration
#url('^accounts/', include('registration.urls')),
url(r'^accounts/', include('registration.backends.simple.urls')),
#url(r'^accounts/login/$', 'django.contrib.auth.views.login'),
#url(r'^accounts/login/$', 'reviews.views.login'),
url('^accounts/logout/$', 'django.contrib.auth.views.logout', {'next_page' : '/accounts/login'}),
#url('^accounts/profile/$', 'reviews.views.profile'),
#search
#url(r'^search/$', 'reviews.views.search'),
#user profile
#url(r'users/(?P<user>[^/]+)/$', 'reviews.views.profile'),
#social
url('', include('social.apps.django_app.urls', namespace='social')),
#submit reviews
#url(r'^submit/(?P<slug>[^/]+)/review_submit/$','reviews.views.single_product', name='submit-review'),
#category
#url(r'^cat/(?P<cat>[^/]+)/$', 'reviews.views.category', name='category'),
#product
#url(r'^prod/(?P<slug>[^/]+)/$', 'reviews.views.single_product', name='product_detail'),
#google webmaster tools
(r'^googlece9fb428b0c84a39\.html$', lambda r: HttpResponse("google-site-verification: googlece9fb428b0c84a39.html", mimetype="text/plain")),
#robots.txt crawler
(r'^robots\.txt$', lambda r: HttpResponse("User-agent: *\nDisallow: ", mimetype="text/plain")),
)
Это мой домашний html
{% block content %}
<a href="{% url 'social:begin' 'facebook' %}">Facebook OAuth2</a> <br />
<a href="{% url 'social:begin' 'facebook-app' %}">Facebook App</a> <br />
<a href="{% url 'social:begin' 'email' %}">Email Auth</a> <br />
<a href="{% url 'social:begin' 'username' %}">Username Auth</a> <br />
<form action="{% url 'social:begin' 'openid' %}" method="post">{% csrf_token %}
<div>
<label for="openid_identifier">OpenId provider</label>
<input id="openid_identifier" type="text" value="" name="openid_identifier" />
<input type="submit" value="Login" />
</div>
</form>
<form action="{% url 'social:begin' 'livejournal' %}" method="post">{% csrf_token %}
<div>
<label for="openid_lj_identifier">LiveJournal ID</label>
<input id="openid_lj_identifier" type="text" value="" name="openid_lj_user" />
<input type="submit" value="Login" />
</div>
</form>
<form method="post" action="{% url 'social:complete' 'persona' %}">{% csrf_token %}
<input type="hidden" name="assertion" value="" />
<a rel="nofollow" id="persona" href="#">Persona</a>
</form>
{% if plus_id %}
<form id="google-plus" method="post" action="{% url 'social:complete' 'google-plus' %}">{% csrf_token %}
<input id="at" type="hidden" name="access_token" value="" />
<input id="code" type="hidden" name="code" value="" />
<div id="signinButton">
<span class="g-signin" data-scope="{{ plus_scope }}"
data-clientid="{{ plus_id }}"
data-redirecturi="postmessage"
data-accesstype="offline"
data-cookiepolicy="single_host_origin"
data-callback="signInCallback">
</span>
</div>
</form>
{% endif %}
{% endblock %}
urls.py
вашего приложения? - person Drewness   schedule 25.02.2014