Skip to main content

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

  1. Add "eazy_user" to your INSTALLED_APPS setting like this:
INSTALLED_APPS = [
        ...
        'eazy_user',
    ]
  1. 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'
  1. Run python manage.py migrate to apply the migrations to the database.
python manage.py migrate
  1. 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)
  1. 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

MIT

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

eazy-django-user-1.1.1.tar.gz (4.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

eazy_django_user-1.1.1-py3-none-any.whl (5.9 kB view details)

Uploaded Python 3

File details

Details for the file eazy-django-user-1.1.1.tar.gz.

File metadata

  • Download URL: eazy-django-user-1.1.1.tar.gz
  • Upload date:
  • Size: 4.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.8.10

File hashes

Hashes for eazy-django-user-1.1.1.tar.gz
Algorithm Hash digest
SHA256 580354d7cea43476ff20cda1c0476759f0010342e7ef0a493487bf6091966c12
MD5 9f03c1a8f7a7d4d151c0d6a1806b3bcc
BLAKE2b-256 8e12194725a39171b81386847a3b1963fec30b07539188667407e73b4af42940

See more details on using hashes here.

File details

Details for the file eazy_django_user-1.1.1-py3-none-any.whl.

File metadata

File hashes

Hashes for eazy_django_user-1.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 b295dbdb12de42961a0e0fccbd3e5b3b118dd3838d78b60a4a0e8621c755c2b3
MD5 70cf3083b857d43553b665a745c8e319
BLAKE2b-256 a3deafc54c420a551b526b59d0944fa184f88b9827b7248bb34db48c407aec11

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page