Skip to main content

A custom Django user model for best practices email-based login.

Project description

This project provides a custom user model that improves on Django’s default by making a few modern and international changes.

  • Uses email as the username to simplify login for users

  • Replace first_name and last_name with international friendly short_name full name fields

Installation

In a Terminal, use pip to install the package from [PyPI](https://pypi.org/).

pip install django-improved-user

If you intend to use the UserFactory provided by the package to allow for testing with [factory_boy](https://github.com/FactoryBoy/factory_boy), you can specify so during install.

pip install django-improved-user[factory]

If you do not but wish to use the UserFactory, you will need to install [factory_boy](https://github.com/FactoryBoy/factory_boy) yourself.

Usage

Perform the following steps in your settings.py file.

  1. Add improved_user.apps.ImprovedUserConfig (or simply improved_user) to INSTALLED_APPS

  2. Define or replace AUTH_USER_MODEL with he new model, as below.

    AUTH_USER_MODEL='improved_user.User'
  3. In Django > 1.9, change UserAttributeSimilarityValidator to match correct User fields, as shown below.

    AUTH_PREFIX = 'django.contrib.auth.password_validation.'
    AUTH_PASSWORD_VALIDATORS = [
        {
            'NAME': AUTH_PREFIX + 'UserAttributeSimilarityValidator',
            'OPTIONS': {
                'user_attributes': ('email', 'full_name', 'short_name')
            },
        },
        # include other password validators here
    ]

Testing

To run the test suite on a single version of Django (assuming you have a version of Django installed), run the runtests.py script from the root of the project.

$ python runtests.py

You can limit the tests or pass paramaters as if you had called manage.py test.

$ ./runtests.py tests.test_basic -v 3

To run all linters and test multiple Python and Django versions, use tox.

$ tox

You will need to install Python 3.4, 3.5, and 3.6 on your system for this to work.

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

django-improved-user-0.4.0.tar.gz (31.7 kB view hashes)

Uploaded Source

Built Distribution

django_improved_user-0.4.0-py3-none-any.whl (12.3 kB view hashes)

Uploaded Python 3

Supported by

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