Answers for "how to pass user in django without validation"

5

user login validation django

from django.contrib.auth import authenticate, login

def my_view(request):
    username = request.POST['username']
    password = request.POST['password']
    user = authenticate(request, username=username, password=password)
    if user is not None:
        login(request, user)
        # Redirect to a success page.
        ...
    else:
        # Return an 'invalid login' error message.
        ...
Posted by: Guest on June-12-2020
0

loginrequiredmixin django

from django.contrib.auth.mixins import LoginRequiredMixin

class MyView(LoginRequiredMixin, View):
    login_url = '/login/'
    redirect_field_name = 'redirect_to'
Posted by: Guest on June-11-2020

Code answers related to "how to pass user in django without validation"

Python Answers by Framework

Browse Popular Code Answers by Language