如何在 Django 应用中注销 Google 用户?

问题描述

我正在尝试使用 Django 注销 Google 用户。我已经看到这个 post 并且我已经在我的 index.html 文件中写了这个:

<div>
        {% if not status %}
            <a href="/gmailAuthenticate" onclick="gmailAuthenticate()" title="Google">Google</a>
        {% else %}
            <p>Your are verified</p>
            <form id="myform" method="post" action="{% url 'logout' 'google-oauth2' %}5/?next={{request.path }}">
    {% csrf_token %}
    <input type="hidden" name="name" value="value" />
    <a onclick="document.getElementById('myform').submit();">discon</a>
</form>
        {% endif %}
    </div>

我也修改了我的 urls.py:

url(r'^logout',views.logout,name='logout'),

这是我的 views.py 文件

def logout(request):
    auth_logout(request)
    return render_to_response('logged-out.html',{},RequestContext(request))

问题是当我运行它时,我收到此错误

django.urls.exceptions.noreverseMatch: Reverse for 'logout' with arguments '('google-oauth2',)' not found. 1 pattern(s) tried: ['logout']

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)