from django.contrib.auth.models import User try: user = User.objects.get(username='example_username') except User.DoesNotExist: user = None if user: # Access user data here