I would like to make sure that the user who completed the registration, immediately received special permissions.
How to implement it? Is it possible to do this without creating a custom user model?
I would like to make sure that the user who completed the registration, immediately received special permissions.
How to implement it? Is it possible to do this without creating a custom user model?
In order to add certain privileges to the user, a custom model is not necessary. There are several options:
1) You make a view (responsible for registering a user) - it will contain a registration form (most likely, you will use a ModelForm). Keeping the form, you can get the user'a instance, and do anything with it. If you use CreateView for this case, you can override get_success_url or another method where the user instance is already available (user = self.object)
2) you can add privileges through modifying the form (override the save method, for example)
3) Use signals . The most difficult method and its expediency is doubtful. Accordingly, the pre_save or post_save signal (User model, whatever it may be) can be used here.
Source: https://ru.stackoverflow.com/questions/453844/
All Articles