'Ensures that the user is authenticated (e.g. not an AnonymousUser), unless DEBUG mode is enabled.'

def perform_authentication(self, request):

    super(GradeViewMixin, self).perform_authentication(request)
    if request.user.is_anonymous():
        raise AuthenticationFailed
