social-auth-app-django,如何在网址末尾禁止自动斜杠

时间:2018-07-05 02:33:32

标签: django-rest-framework django-socialauth trailing-slash qq

问题已解决。实际上,我已经使用social-auth-app-django实现了“ qq_login”,并且腾讯更新了重定向网址中不应包含“ trailing-slash”的规则,因此我必须对其进行调整。

通过以下方法固定


  1. 将TRAILING_SLASH从“真”变为“假”
  2. 删除网址中的“ $”

social_django.urls.py

extra = getattr(settings, setting_name('TRAILING_SLASH'), False) and '/' or ''
app_name = 'social'
urlpatterns = [
# authentication / association
url('^login/(?P<backend>[^/]*){0}'.format(extra), views.auth,
    name='begin'),
url('^complete/(?P<backend>[^/]*){0}'.format(extra), views.complete,
    name='complete'),]

0 个答案:

没有答案