custom-user-profiles-1.2.0
توضیحات
Create custom-user profiles easily
| ویژگی | مقدار |
|---|---|
| سیستم عامل | - |
| نام فایل | custom-user-profiles-1.2.0 |
| نام | custom-user-profiles |
| نسخه کتابخانه | 1.2.0 |
| نگهدارنده | [] |
| ایمیل نگهدارنده | [] |
| نویسنده | Diogo Laginha |
| ایمیل نویسنده | diogo.laginha.machado@gmail.com |
| آدرس صفحه اصلی | https://github.com/laginha/custom-user-profiles |
| آدرس اینترنتی | https://pypi.org/project/custom-user-profiles/ |
| مجوز | MIT |
Quick start
-------------------
Add to ``INSTALLED_APPS`` setting
::
INSTALLED_APPS = (
# ...
'custom_user',
'custom_user_profiles
)
Set `AUTH_USER_MODEL` setting
::
AUTH_USER_MODEL = 'custom_user_profiles.CustomUser'
the `CustomUser` inherit from `AbstractEmailUser` model from [django-custom-user](https://github.com/jcugat/django-custom-user)
If you want to create your own custom user, extend `custom_user_profiles.models.AbstractCustomUser`.
::
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 and inherit from django's `BaseUserManager`
نحوه نصب
نصب پکیج whl custom-user-profiles-1.2.0:
pip install custom-user-profiles-1.2.0.whl
نصب پکیج tar.gz custom-user-profiles-1.2.0:
pip install custom-user-profiles-1.2.0.tar.gz