“Logout Django” Kode Jawaban

Logout Django

from django.contrib.auth import logout

def logout_view(request):
    logout(request)
    # Redirect to a success page.
Crazy Chinchilla

Pengguna Logout Django

 def logout_request(request):
      logout(request)
      return redirect("")
Virgin Programmer

LoginRequiredMixin

from django.contrib.auth.mixins import LoginRequiredMixin

LOGIN_URL = 'your_url'
Virgin Programmer

Cara Membuat Formulir Django Login yang Bagus

{% extends 'main/header.html' %}

{% block content %}

    <div class="container">
        <form method="POST">
        {% csrf_token %}
        {{form.as_p}}
            <button style="background-color:#F4EB16; color:blue" class="btn btn-outline-info" type="submit">Login</button>
        </form>
        Don't have an account? <a href="/register" target="blank"><strong>register here</strong></a>!
    </div>
{% endblock %}
Lucky Lark

LoginRequiredMixin Django

from django.contrib.auth.mixins import LoginRequiredMixin

class MyView(LoginRequiredMixin, View):
    login_url = '/login/'
    redirect_field_name = 'redirect_to'
Fragile Fox

Jawaban yang mirip dengan “Logout Django”

Pertanyaan yang mirip dengan “Logout Django”

Lebih banyak jawaban terkait untuk “Logout Django” di Python

Jelajahi jawaban kode populer menurut bahasa

Jelajahi bahasa kode lainnya