[Answer]-Django redirect shortcut changes request.user

1👍

A redirect causes a whole new request from the user’s browser, hence the user object has to be fetched from the database again based on the session cookie and assigned to request.user. This happens in the authentication middleware. Unless you’ve written your own version of this, it’s always going to use the default user class.

This is just one of the reasons why it’s a bad idea to subclass User. Instead, extend it with a UserProfile class with a OneToOne relation to User.

Leave a comment