Skip to main content

Provides an abstract base User model without first and last name fields.

Project description

Updates https://badge.fury.io/py/django-simple-user.svg https://travis-ci.org/valerymelou/django-simple-user.svg?branch=master https://codecov.io/gh/valerymelou/django-simple-user/branch/master/graph/badge.svg

Provides a simple abstract User model without first and last name fields.

Documentation

The full documentation is available at https://django-simple-user.readthedocs.io.

Quickstart

Install Django Simple User:

pip install django-simple-user

Features

  • 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

Usage

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.

Bonuses

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

Note

Always remember to set your extended User model as the authentication User model by setting AUTH_USER_MODEL in your settings file.

Running Tests

Does the code actually work?

source <YOURVIRTUALENV>/bin/activate
(myenv) $ pip install tox
(myenv) $ tox

Credits

Tools used in rendering this package:

History

0.1.0 (2018-05-31)

  • First release on PyPI.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for django-simple-user, version 0.1.2
Filename, size File type Python version Upload date Hashes
Filename, size django_simple_user-0.1.2-py2.py3-none-any.whl (5.5 kB) File type Wheel Python version 3.6 Upload date Hashes View hashes
Filename, size django-simple-user-0.1.2.tar.gz (7.4 kB) File type Source Python version None Upload date Hashes View hashes

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN SignalFx SignalFx Supporter DigiCert DigiCert EV certificate StatusPage StatusPage Status page