Modular user model for Django
Project description
# Modular user model for Django
[![PyPI version](https://badge.fury.io/py/django-modular-user.svg)](https://badge.fury.io/py/django-modular-user)
**django-modular-user** lets you easily customize Django's User model, without any compromises. Unlike Django's own `AbstractBaseUser`, here nothing is irremovable, you can use exactly the parts you want.
## Requirements
* Django 2.0+
## Installation
```sh
pip install django-modular-user
```
* Create a new Django package with following models.py, and a migrations/ subdirectory:
```python
from django_modular_user.user import AbstractUser
class User(AbstractUser):
pass
```
* In `settings.py`, set `AUTH_USER_MODEL = 'your_new_package_name.User'`
* Run `./manage.py makemigrations`
## Configuration
You may configure the basic profile data with `USER_CORE_MODULES` setting. For example, to create an User model without usernames and passwords, that uses email as the username, you may use:
```python
USER_CORE_MODULES = [
'django_modular_user.user:AbstractBaseUser',
'django_modular_user.user:EmailMixin', # email
'django_modular_user.user:NamePartsMixin', # given_name, middle_name, family_name
'django_modular_user.user:ActiveMixin', # is_active
'django_modular_user.user:StaffMixin', # is_staff
'django_modular_user.user:PermissionsMixin', # is_superuser and other permissions
'django_modular_user.user:JoinedMixin', # date_joined
]
USERNAME_FIELD = 'email'
USER_EMAIL_UNIQUE = True
```
## App-specific User mixins
`django-modular-user` automatically scans all `INSTALLED_APPS` for `user.py` modules that contain a `UserMixin` class. Such mixins are automatically added to the User model; you only need to run `./manage.py makemigrations` after adding an app to your `INSTALLED_APPS` list.
[![PyPI version](https://badge.fury.io/py/django-modular-user.svg)](https://badge.fury.io/py/django-modular-user)
**django-modular-user** lets you easily customize Django's User model, without any compromises. Unlike Django's own `AbstractBaseUser`, here nothing is irremovable, you can use exactly the parts you want.
## Requirements
* Django 2.0+
## Installation
```sh
pip install django-modular-user
```
* Create a new Django package with following models.py, and a migrations/ subdirectory:
```python
from django_modular_user.user import AbstractUser
class User(AbstractUser):
pass
```
* In `settings.py`, set `AUTH_USER_MODEL = 'your_new_package_name.User'`
* Run `./manage.py makemigrations`
## Configuration
You may configure the basic profile data with `USER_CORE_MODULES` setting. For example, to create an User model without usernames and passwords, that uses email as the username, you may use:
```python
USER_CORE_MODULES = [
'django_modular_user.user:AbstractBaseUser',
'django_modular_user.user:EmailMixin', # email
'django_modular_user.user:NamePartsMixin', # given_name, middle_name, family_name
'django_modular_user.user:ActiveMixin', # is_active
'django_modular_user.user:StaffMixin', # is_staff
'django_modular_user.user:PermissionsMixin', # is_superuser and other permissions
'django_modular_user.user:JoinedMixin', # date_joined
]
USERNAME_FIELD = 'email'
USER_EMAIL_UNIQUE = True
```
## App-specific User mixins
`django-modular-user` automatically scans all `INSTALLED_APPS` for `user.py` modules that contain a `UserMixin` class. Such mixins are automatically added to the User model; you only need to run `./manage.py makemigrations` after adding an app to your `INSTALLED_APPS` list.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
django-modular-user-0.1.0.tar.gz
(10.3 kB
view hashes)
Built Distribution
Close
Hashes for django-modular-user-0.1.0.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 82202b06f8b7e29ed443a5f5391f0a3e64615174d9a445b1567036c06ce03ab1 |
|
MD5 | bc5a017a40ac04c4751673cc3d503027 |
|
BLAKE2b-256 | 4282710f476ca78ee910bb5f4ef861926e554fc9ba0d16e68cea8f9767779232 |
Close
Hashes for django_modular_user-0.1.0-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2968a3796dfa0e5ed0c120f0d67cb711abb29fa293df75b1bf1f322400679414 |
|
MD5 | 78ec1ef225eb36b7b5102f52b0267e9d |
|
BLAKE2b-256 | 8cbf9b1a8f0362dab9a20139c0b47ef510c9882a1f7e6c5c8e0fc1da91c812c6 |