Provides an abstract base User model without first and last name fields.
Provides a simple abstract User model without first and last name fields.
The full documentation is available at https://django-simple-user.readthedocs.io.
Install Django Simple User:
pip install django-simple-user
- Abstract User model without the fields first_name and last_name
- Abstract User model without the fields first_name, last_name and email
- Abstract User model without the fields first_name, last_name and username
If you are like me, you might have found yourself extending django.contrib.auth.base_user.AbstractBaseUser just to remove the first_name and last_name fields from your final User model. I was tired of doing that and I created this package. It defines an abstract User model without those fields so that you can just inherit from it to create your User model. Let’s suppose you have a users app with a models.py file containing the following:
from simple_user.models import AbstractUser class User(AbstractUser): pass
Then in your settings file:
AUTH_USER_MODEL = 'users.User'
This will create a User model with all the fields that happen to exists in the default Django’s User model except first_name and last_name and use it for authentication in your app.
There are some cases where you only want username or email but not both fields in your model. Django Simple User has got you covered. You can use SimpleUserWithUsername or SimpleUserWithEmail to achieve each scenario.
For a User model with username as identifying field but without first_name, last_name and email do:
from simple_user.models import SimpleUserWithUsername class User(SimpleUserWithUsername): pass
For a User model with email as identifying field but without first_name, last_name and username do:
from simple_user.models import SimpleUserWithUsername class User(SimpleUserWithEmail): pass
Always remember to set your extended User model as the authentication User model by setting AUTH_USER_MODEL in your settings file.
Does the code actually work?
source <YOURVIRTUALENV>/bin/activate (myenv) $ pip install tox (myenv) $ tox
- First release on PyPI.
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
|Filename, size & hash SHA256 hash help||File type||Python version||Upload date|
|django_simple_user-0.1.2-py2.py3-none-any.whl (5.5 kB) Copy SHA256 hash SHA256||Wheel||3.6|
|django-simple-user-0.1.2.tar.gz (7.4 kB) Copy SHA256 hash SHA256||Source||None|