You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
With LoggingMixin set on my ViewSet, if an anonymous user hits an endpoint, drf_api_tracking throws an error:
'NoneType' object has no attribute 'is_anonymous'
It comes from BaseLoggingMixin._get_user(), specifically the line where it does if user.is_anonymous: since user is None in this case it fails.
A temporary work around for now is to do a monkey patch like so:
# monkey patch a bug in rest_framework_tracking
def fixed_get_user(self, request):
user = request.user
if not user or user.is_anonymous:
return None
return user
BaseLoggingMixin._get_user = fixed_get_user
The text was updated successfully, but these errors were encountered:
With LoggingMixin set on my ViewSet, if an anonymous user hits an endpoint, drf_api_tracking throws an error:
'NoneType' object has no attribute 'is_anonymous'
It comes from
BaseLoggingMixin._get_user()
, specifically the line where it doesif user.is_anonymous:
since user is None in this case it fails.A temporary work around for now is to do a monkey patch like so:
The text was updated successfully, but these errors were encountered: