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

def perform_authentication(self, request):

    super(CourseViewMixin, self).perform_authentication(request)
    if (request.user.is_anonymous() and (not settings.DEBUG)):
        raise AuthenticationFailed
