1
I’m using Django 1.11 and class-based views. My user model is customized and in it I have a "status" field where it has "enabled, blocked and disabled". I would like to know how I can allow the login only of users who are enabled, and others are barred.
It’s been worth it to everyone !
That is the answer, although with the title of the question quite different, and, maybe you end up seeing that Django itself provides you with mechanisms for user status. Pay attention in the middle of the view code, have exactly what you want:
if user.is_active: ...
– Sidon
That’s not what I want yet. But thank you. In my case I have 3 status that at the model level are an Enum (business rule). In the case of the is_active method I believe it is not for this purpose.
– Leonardo Freitas
You can have as many status as you want, just extend the tables
auth_user
,auth_user_groups
andauth_user_user_permissions
– Sidon