class MyUser(User):
class Meta:
proxy = True
def do_something:
...
With the above, I extend the behavior of the Django User Model using the proxy model technique. I was hoping that I could somehow customize request.user, so that MyUser instance, instead of User instance, is assigned to it every time. How could I implement that, if possible?
You can inherit a new middleware class from AuthMiddleware or create a separate middleware which will process request after django’s auth and change request.user to your user instance.