I want to differentiate the users model, have premium and regular users. How do I implement that in Django, should it be in the users class or is there another approach ?
2 Answers
There's two relatively simple ways. The first is groups - see the groups docs here:
Groups can be assigned permissions that you can then check for. That way you only need to add the user to the group, rather than assigning each user each permission. This is especially useful when there are lots of different permissions sets. Then you can check if a user belongs to a group as per this question, or check for specific permissions.
If there's not a lot of other permissions involved, you might want to simply add a field to a Custom User, (the docs recommend always using a custom user) eg:
from django.contrib.auth.models import AbstractUser
class CustomUser(AbstractUser):
is_premium = models.BooleanField(default=False)
And then adding the following in your settings.py
AUTH_USER_MODEL = '<myapp>.CustomUser'
AbstractUser is a class set up to allow you to extend the normal user without breaking anything else. With that field you can easily test, for example:
if request.user.is_premium:

- 4,629
- 1
- 4
- 16
You can actually already do that with the available functionalities. Django already has groups, and you can attach permissions to groups.
This thus means that you can define a group named "premium" and for example attach permissions to that premium group that non-premium users will not have. Then you can add users to that group.
For more information, read the permissions and authorization section of the documentation.

- 443,496
- 30
- 428
- 555