diff --git a/raven/contrib/django/client.py b/raven/contrib/django/client.py index 1d84c1ab4..a1613426e 100644 --- a/raven/contrib/django/client.py +++ b/raven/contrib/django/client.py @@ -12,6 +12,7 @@ import time import logging +from django import VERSION as DJANGO_VERSION from django.conf import settings from django.core.exceptions import SuspiciousOperation from django.http import HttpRequest @@ -37,6 +38,14 @@ __all__ = ('DjangoClient',) +if DJANGO_VERSION < (1, 10): + def is_authenticated(request_user): + return request_user.is_authenticated() +else: + def is_authenticated(request_user): + return request_user.is_authenticated + + class _FormatConverter(object): def __init__(self, param_mapping): @@ -152,15 +161,9 @@ def get_user_info(self, request): return user_info try: - if hasattr(user, 'is_authenticated'): - # is_authenticated was a method in Django < 1.10 - if callable(user.is_authenticated): - authenticated = user.is_authenticated() - else: - authenticated = user.is_authenticated - if not authenticated: - return user_info - + authenticated = is_authenticated(user) + if not authenticated: + return user_info user_info['id'] = user.pk if hasattr(user, 'email'):