How to block user login with certain "status" in Django

Asked

Viewed 249 times

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: ...

  • 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.

  • You can have as many status as you want, just extend the tables auth_user, auth_user_groups and auth_user_user_permissions

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.