Skip to main content
Join the official 2019 Python Developers SurveyStart the survey!

A user for djangorestframework that uses an email as the username.

Project description


A user for djangorestframework that uses an email as the username.


  • Use email as username for loging in
  • One name field instead of first name and last name
  • Endpoints for creating an account, viewing, and updating accounts
  • Django admin to work with EmailUser model.


  • Python 3.5+
  • Django 2.2+
  • Djangorestframework 3.10+

Installation and Configuration

Install using pip:

$ pip install djangorestframework_emailuser

Add 'emailuser' to INSTALLED_APPS:

# mysite/

Add the following line to to override django’s default User model with the ‘EmailUser’ model:

# mysite/
AUTH_USER_MODEL = 'emailuser.EmailUser'

Add urls to url conf:

# mysite/
from django.urls import path, include
urlpatterns = [
  path('accounts/', include('emailuser.urls')),


To create a user programatically:

from django.contrib.auth import get_user_model

normal_user = get_user_model().objects.create_user(
    name='My Name',

superuser = get_user_model().objects.create_superuser(
    name='Super Name',

Using Endpoints:

Assuming emailuser urls were set to /accounts/:

Creating user

POST {"email": email, "name": name, "password": password} to /accounts/users/register

Updating User

PUT {"email": email, "name": name, "password": password} to /accounts/users/<int:pk>/ or PATCH the attribute you want to change to /accounts/users/<int:pk>/

Referencing User

To reference user object in your code as a string (As for foreign keys):

from django.conf import settings

user_model = settings.AUTH_USER_MODEL

To reference the user class directly:

from django.contrib.auth import get_user_model

user_model = get_user_model()

See Django docs for more details.


The EmailUser model has the following attributes:

The email address used as the login username.
A single field for the name of the user.
The password is hashed as set by the django settings.
A boolean attribute that can only be set programatically.
A boolean attribute that can be set by the admin site or programatically.

EmailUser also subclasses django.contrib.auth.models.PermissionsMixin.

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 djangorestframework-emailuser, version 0.1.1.dev1
Filename, size File type Python version Upload date Hashes
Filename, size djangorestframework_emailuser-0.1.1.dev1-py3-none-any.whl (7.6 kB) File type Wheel Python version py3 Upload date Hashes View hashes
Filename, size djangorestframework_emailuser-0.1.1.dev1.tar.gz (5.6 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