Answers for "django loggin"

5

django login

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
1

django logger

import logging

logging.basicConfig(level=logging.WARNING)
logger = logging.getLogger(__name__)
logger.setLevel(logging.DEBUG)

# USE THIS 
logger.debug('hello')
Posted by: Guest on March-13-2021

Python Answers by Framework

Browse Popular Code Answers by Language