(Beta) Simple and flexible way to swap default Django User
Project description
Django-Swap-User (Beta)
About
If you are tired from copying one custom user model from one project to another ones - use this package. This will do all for you.
Installation
pip install django-swap-user
Basic usage
- Choose one of models and settings from table:
Application name | Username field | Description | INSTALLED_APPS |
AUTH_USER_MODEL |
---|---|---|---|---|
to_email |
email |
User with email username |
"swap_user", "swap_user.to_email", |
"to_email.EmailUser" |
to_named_email |
email |
User with email username, first_name and last_name extra fields |
"swap_user", "swap_user.to_named_email", |
"to_named_email.NamedEmailUser" |
to_phone |
phone |
User with phone username |
"swap_user", "swap_user.to_phone", |
"to_phone.PhoneUser" |
to_phone_otp |
phone |
User with phone username and OTP authentication |
"swap_user", "swap_user.to_phone_otp", |
"to_phone.PhoneOTPUser" |
- Add corresponding app to
INSTALLED_APPS
:
INSTALLED_APPS = [
...
"swap_user",
"swap_user.to_named_email",
...
]
- Change
AUTH_USER_MODEL
to corresponding:
AUTH_USER_MODEL = "to_named_email.NamedEmailUser"
Architecture
Application swap_user
split into 3 apps:
to_email
- provides user withemail
username fieldto_named_email
- provides user withemail
username field and withfirst_name
,last_name
extra fieldsto_phone
- provides user withphone
username fieldto_phone_otp
- provides user withphone
username field and with OTP authentication
Why?
Because if we leave them in one app, they all will create migrations and tables - such approach leads us to redundant tables. They will be treated as 3 custom models within the same app, which causes perplexing and cognitive burden.
With such approach (when there is a common app which contains internal apps) - the user choose and connect only the specific user model which suits best for concrete business-logic.
I have found such approach at Django REST Framework authtoken
application and decide to use it - reference is here.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for django_swap_user-0.5.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 071ddf72aca41c6a5bff34bc6c8a1ea982163ea26ee411c441624a56447f7e31 |
|
MD5 | de9c6f70158077f56220f194e2f58f09 |
|
BLAKE2b-256 | 53569a9e91d1d915abe9bb9cee8f84a17c2e1afd9fee5d5cc6669a323d04cb3a |