Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

django login code

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.
        ...
Comment

django login page

from django.contrib.auth import authenticate, login
fro django.shortcuts import render, redirect

def login_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.
        return redirect('/')
        ...
    else:
        # Return an 'invalid login' error message.
        ...
        context = {'error':'Invalid username or password.'}
        return render(request, '/login.html', context)
        
               
Comment

django login

def login_view(request):
    if request.method == 'GET':
        cache.set('next', request.GET.get('next', None))

    if request.method == 'POST':
        # do your checks here

        login(request, user)

        next_url = cache.get('next')
        if next_url:
            cache.delete('next')
            return HttpResponseRedirect(next_url)

    return render(request, 'account/login.html')
Comment

login system in django

LOGOUT_REDIRECT_URL = 'your_url'
Comment

PREVIOUS NEXT
Code Example
Python :: python sort list 
Python :: python private 
Python :: remove last element from list python 
Python :: pyspark group by and average in dataframes 
Python :: size of the query process in python BigQuery 
Python :: type string python 
Python :: sort columns dataframe 
Python :: string to dictionary python 
Python :: tkinter allign 
Python :: drop list of columns pandas 
Python :: how to unpivot dataframe pandas 
Python :: only keep rows of a dataframe based on a column value 
Python :: pandas dataframe get number of occurrence in column 
Python :: split word python 
Python :: pdf to csv conversion 
Python :: python add one 
Python :: numpy save multiple arrays 
Python :: python replace all in list 
Python :: python upper 
Python :: fill nan values with mean 
Python :: flask remove file after send_file 
Python :: pandas convert column to datetime 
Python :: input numpy array 
Python :: python list elements 
Python :: clean column names pandas 
Python :: run flask in debug mode 
Python :: append python 
Python :: get dictionary value python 
Python :: python list of dictionaries to excel 
Python :: access first element of dictionary python 
ADD CONTENT
Topic
Content
Source link
Name
9+6 =