I have the following method:
def _attempt(actor): if actor.__class__ != User: raise TypeError
What is called from the view:
self.object.attempt(self.request.user)
As you can see, the _attempt method assumes that the actor will be of type django.contrib.auth.models.User , however the object looks like the type django.utils.functional.SimpleLazyObject . Why is this so? And more importantly, how can I convert a LazyObject (which is apparently a kind of wrapper for the User object) to a User object?
Additional information about Request.user is available here: https://docs.djangoproject.com/en/dev/ref/request-response/#django.http.HttpRequest.user This documentation states that Request.user must be a User object ...
====== after editing =====
Now I have the following method:
def _attempt(obj, action, actor, msg): actor.is_authenticated() if isinstance(actor, LazyObject): print type(actor)
I pass the user, however, if condition is still true, the actor is still LazyObject . Why is this so?
python django django-users django-contrib
Himerzi Jul 03 2018-12-12T00: 00Z
source share