Sunday, July 24, 2011

Django get user object in views.py

In views.py
def index(request):
    # get user
    try:
        the_user = User.objects.get(username = request.user)
    except User.DoesNotExist:
        return HttpResponse("Invalid username")

1 comment: