djangotastypie

How can I get the logged user in tastypie?


I want to get the logged user in the dehydrate method of the class derived from ModelResource in Tastypie.

How can I do that?


Solution

  • Found it. There is request object in bundle;

    def dehydrate(self,bundle):
        logged_user = bundle.request.user
        ...
        return bundle
    

    This works fine.