custom-user-profiles
Create custom-user profiles easily with this simple app.
Install
pip install custom_user_profiles
Quick start
INSTALLED_APPS
setting
add to INSTALLED_APPS = (
# ...
'custom_user',
'custom_user_profiles
)
AUTH_USER_MODEL
setting
set AUTH_USER_MODEL = 'custom_user_profiles.CustomUser'
The
CustomUser
inherit fromAbstractEmailUser
model from django-custom-user
If you want to create your own custom user
from custom_user_profiles.models import AbstractCustomUser
class CustomUser(AbstractCustomUser):
# ...
create your profile models
from custom_user_profiles.models import Profile
class Buyer(Profile):
# ...
class Seller(Profile):
# ...
Usage
@login_required
def view(request):
profile = request.user.profile
if request.user.is_seller:
...
Also AbstractCustomUser
provides a chainable QuerySet
manager:
from django.contrib.auth import get_user_model
User = get_user_model()
User.queryset.seller() # get all users with 'seller' profile
User.queryset.buyer() # get all users with 'buyer' profile
User.queryset.something() # raises django.core.exceptions.FieldError
objects
manager is still available (e.g.User.objects.create(...)
).