I am trying to type the following:
user: Final[CustomUser] = self.request.user
Where CustomUser
is my custom user model defined in settings.py
. My IDE complains that Expected type 'CustomUser', got 'AbstractBaseUser' instead
. Looking at the documentation, it says that self.request.user
returns an instance of AUTH_USER_MODEL
however clearly this is not happening.
Also tried:
def get(self, request: MyRequest, *args, **kwargs) -> HttpResponse:
user: Final[CustomUser] = self.request.user
Where
from django.http import HttpRequest
from my_user_app.models import CustomUser
class MyRequest(HttpRequest):
user: CustomUser