An improved custom user model for django projects
Project description
Django Modern User
Django Modern User is a custom user model for Django projects that replaces the default username
field with a case-insensitive email
field for authentication, and removes the requirement for first and last names. This model aims to provide a more practical and modern approach to user management in Django.
Installation
-
Install
django-modern-user
via pip:python -m pip install django-modern-user
-
Add
django_modern_user
to yourINSTALLED_APPS
in your Django settings:INSTALLED_APPS = [ # ... other apps 'django_modern_user', ]
-
Set
django_modern_user.ModernUser
as your user model:AUTH_USER_MODEL = "django_modern_user.ModernUser"
-
Run migrations to create the necessary database table:
python manage.py migrate
Usage
With django-modern-user
, authentication is done using the email field. The email field is case-insensitive, ensuring a user-friendly authentication process.
Here's an example of how you might create a new user:
from django_modern_user.models import ModernUser
# Create a new user
user = ModernUser.objects.create_user(email='example@example.com', password='password123')
# Create a superuser
superuser = ModernUser.objects.create_superuser(email='admin@example.com', password='password123')
Custom User Manager
django-modern-user
comes with a custom user manager, UserPlusManager
, which handles user creation and ensures the email field is used for authentication.
Further Customization
You can further customize the ModernUser
model and UserPlusManager
to meet the specific needs of your project.
Contributing
Feel free to fork the project, open a PR, or submit an issue if you find bugs or have suggestions for improvements.
License
This project is licensed under the MIT License. See the LICENSE file for details.
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
File details
Details for the file django_modern_user-0.1.3.tar.gz
.
File metadata
- Download URL: django_modern_user-0.1.3.tar.gz
- Upload date:
- Size: 5.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.5.1 CPython/3.10.4 Linux/5.15.90.1-microsoft-standard-WSL2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 82d8adf5aa50e26ef5c47a746b9d213ab4c1ee0b4a8c159b953b87d4b045616d |
|
MD5 | ef955e329d9909bb76ee7444a816705c |
|
BLAKE2b-256 | 8c9e6bb949a9de371a69620b5d4abd332329ca2a0fc04ba5dd87cb73c3c0f565 |
File details
Details for the file django_modern_user-0.1.3-py3-none-any.whl
.
File metadata
- Download URL: django_modern_user-0.1.3-py3-none-any.whl
- Upload date:
- Size: 9.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.5.1 CPython/3.10.4 Linux/5.15.90.1-microsoft-standard-WSL2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | b466cdeba0710766753484019ac2b83359fef5d6d5cc05e95a959286e7d6641a |
|
MD5 | a0853bfaf48ff84dbb212b9465a7b26f |
|
BLAKE2b-256 | 7c7eae3de0b8850ad56b97df090cbff70dd03ce2c4b728d6f5e930e4a30432cb |