Commit 37ea3567 authored by Linus Lewandowski's avatar Linus Lewandowski

DRF: Thanks for your help, but we really know better who is the request.user.

parent c2bcbf0e
Pipeline #16826717 passed with stages
in 4 minutes and 9 seconds
from django.apps import AppConfig
from django.http import HttpRequest
from rest_framework.request import Request
class DjangoRequestUserConfig(AppConfig):
name = 'django_request_user'
def ready(self):
from .request_user import request_user
from .request_user import request_user, drf_request_user
HttpRequest.user = request_user
Request.user = drf_request_user
......@@ -44,3 +44,12 @@ def set_request_user(request, user):
request._user = None
request_user = property(get_request_user, set_request_user)
def drf_get_request_user(request):
return request._request.user
def drf_set_request_user(request, user):
request._request.user = user
drf_request_user = property(drf_get_request_user, drf_set_request_user)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment