5656except ImportError :
5757 raise DidNotEnable ("Django not installed" )
5858
59+ from sentry_sdk .integrations .django .caching import patch_caching
5960from sentry_sdk .integrations .django .transactions import LEGACY_RESOLVER
6061from sentry_sdk .integrations .django .templates import (
6162 get_template_frame_from_exception ,
6566from sentry_sdk .integrations .django .signals_handlers import patch_signals
6667from sentry_sdk .integrations .django .views import patch_views
6768
68- if DJANGO_VERSION [:2 ] > (1 , 8 ):
69- from sentry_sdk .integrations .django .caching import patch_caching
70- else :
71- patch_caching = None # type: ignore
72-
7369from typing import TYPE_CHECKING
7470
7571if TYPE_CHECKING :
9086 from sentry_sdk ._types import Event , Hint , EventProcessor , NotImplementedType
9187
9288
93- if DJANGO_VERSION < (1 , 10 ):
94-
95- def is_authenticated (request_user ):
96- # type: (Any) -> bool
97- return request_user .is_authenticated ()
98-
99- else :
100-
101- def is_authenticated (request_user ):
102- # type: (Any) -> bool
103- return request_user .is_authenticated
104-
105-
10689TRANSACTION_STYLE_VALUES = ("function_name" , "url" )
10790
10891
@@ -597,7 +580,7 @@ def _set_user_info(request, event):
597580
598581 user = getattr (request , "user" , None )
599582
600- if user is None or not is_authenticated ( user ) :
583+ if user is None or not user . is_authenticated :
601584 return
602585
603586 try :
@@ -624,20 +607,11 @@ def install_sql_hook():
624607 except ImportError :
625608 from django .db .backends .util import CursorWrapper
626609
627- try :
628- # django 1.6 and 1.7 compatability
629- from django .db .backends import BaseDatabaseWrapper
630- except ImportError :
631- # django 1.8 or later
632- from django .db .backends .base .base import BaseDatabaseWrapper
610+ from django .db .backends .base .base import BaseDatabaseWrapper
633611
634- try :
635- real_execute = CursorWrapper .execute
636- real_executemany = CursorWrapper .executemany
637- real_connect = BaseDatabaseWrapper .connect
638- except AttributeError :
639- # This won't work on Django versions < 1.6
640- return
612+ real_execute = CursorWrapper .execute
613+ real_executemany = CursorWrapper .executemany
614+ real_connect = BaseDatabaseWrapper .connect
641615
642616 @ensure_integration_enabled (DjangoIntegration , real_execute )
643617 def execute (self , sql , params = None ):
0 commit comments