django username id code example
Example 1: django request user
def my_view(request):
if not request.user.is_authenticated:
return render(request, 'myapp/login_error.html')
Example 2: how to get user id django
def sample_view(request):
current_user = request.user
print current_user.id