K
K
kazhuravlev2014-05-19 11:10:12
Django
kazhuravlev, 2014-05-19 11:10:12

Django: lightweight users?

Task:
- Divide the logic of working with users into 2 parts:
- Administrators (moderators, whatever)
- Application
users - application users have practically nothing (no groups, rights, passwords, usernames, email). only some profile in which all nonsense is stored
- it is necessary to be able to work with some duplicate of the User model, the data of which would be truncated to a single identifier and would not intersect with the standard table.
In general, I'm just wondering how you can solve such a problem.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
P
Pavel Solovyov, 2014-05-19
@pavel_salauyou

Need to use ACL, https://www.djangopackages.com/grids/g/perms/

F
freydev, 2014-05-22
@freydev

Django 1.6 introduced the ability to completely override the User model by extending AbstractBaseUser and setting AUTH_USER_MODEL = 'login.NewUserProfile' in settings.py

class UserNewProfile(AbstractBaseUser):
    user_id = models.CharField(max_length=255, unique=True)
    # password уже определен в AbstactBaseUser
    # любые поля

    USERNAME_FIELD = 'user_id'
    REQUIRED_FIELDS = []

So we have a user entity without required fields, including a password, you won’t be able to log into the admin panel without a password, but the user himself with his own set of fields will exist.
To solve your problem, you may need to write your own manager from BaseUserManager. When you blueprint such a user model, all other tables like groups and rights will not be created, and you will also have to write a class for the admin panel, otherwise users will not be displayed.
You can read about it here https://docs.djangoproject.com/en/dev/topics/auth/...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question