I want to know how do i limit the access of specific users to only one page once they’re logged in.
I have in my User model
deactivated = models.BooleanField(default=False)
If the user is logged in and their account is deactivated I want to only show them a deactivation page. I don’t want to allow them to go anywhere else on the website unless they activate their account again.
What’s the best and the most simple way to implement that?
EDIT: I can’t afford going through every view I have and attach a decorator to it.
If you don’t want to use the decorator approach, your best bet is to write a middleware that checks if
request.useris activated or not, then redirect (to a page where they can reactivate their account preferably) when necessary.Roughly you’d want something like this: