request.user in django code example
Example 1: django import user
from django.contrib.auth.models import User
Example 2: django request user
def my_view(request):
if not request.user.is_authenticated:
return render(request, 'myapp/login_error.html')
Example 3: import login required
from django.contrib.auth.decorators import login_required