Custom User Model
Project description
Eazy Django User
Eazy Django User is a django package that provides a user model with user email as the identifier.
Installation
Use the package manager pip to install foobar.
pip install eazy-django-user
Usage
- Add "eazy_user" to your INSTALLED_APPS setting like this:
INSTALLED_APPS = [
...
'eazy_user',
]
- set AUTH_USER_MODEL in setting.py to "eazy_user.EmailUser" like this: Note: Add this setting before initial migration else there will be clashes with the default user model.
AUTH_USER_MODEL = 'eazy_user.EmailUser'
- Run
python manage.py migrate
to apply the migrations to the database.
python manage.py migrate
- You can access the user foreign key like this:
from django.conf import settings
User = settings.AUTH_USER_MODEL
class YourModel(models.Model):
user = models.ForeignKey(User, on_delete=models.CASCADE)
- Or by using the get_user_model method.
from django.contrib.auth import get_user_model
User = get_user_model()
But you would most likely want to extend the python EmailUser
model you can do that easily:
from eazy_user.models import EmailUser
class YourCustomUser(EmailUser):
....
Whatever you choose, make sure to set the resulting user model as the python AUTH_USER_MODEL
in the settings.py file
AUTH_USER_MODEL = '<your_app_name>.<YourCustomUser>' """<your_app_name> refers to the app that contains your custom user model, while <YourCustomUser> is the custom user model."""
Now you can proceed to creating a super user bash python manage.py createsuperuser
like you normaly would, and enjoy :)
License
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
eazy-django-user-1.1.1.tar.gz
(4.5 kB
view hashes)
Built Distribution
Close
Hashes for eazy_django_user-1.1.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b295dbdb12de42961a0e0fccbd3e5b3b118dd3838d78b60a4a0e8621c755c2b3 |
|
MD5 | 70cf3083b857d43553b665a745c8e319 |
|
BLAKE2b-256 | a3deafc54c420a551b526b59d0944fa184f88b9827b7248bb34db48c407aec11 |