request.user.is_authenticated code example

Example 1: django user fields

# Django User Model Fields
username
first_name
last_name
email
password
groups
user_permissions
is_staff
is_active
is_superuser
last_login
date_joined

Example 2: loginrequiredmixin

from django.contrib.auth.mixins import LoginRequiredMixin

LOGIN_URL = 'your_url'

Example 3: how to create staff account in django

user = User.objects.create_user('john', '[email protected]', 'johnpassword')  
user.is_staff=True 
user.save()

Example 4: import login required

from django.contrib.auth.decorators import login_required