This release is a pre-release and may not be stable for production use.
djangorestframework_emailuser
Overview
A user for djangorestframework that uses an email as the username.
Features
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.
Requirements
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/settings.py
INSTALLED_APPS = [
...
'emailuser',
]
Add the following line to settings.py to override django’s default User model with the ‘EmailUser’ model:
# mysite/settings.py
AUTH_USER_MODEL = 'emailuser.EmailUser'
Add urls to url conf:
# mysite/urls.py
from django.urls import path, include
urlpatterns = [
...
path('accounts/', include('emailuser.urls')),
]
Using
To create a user programatically:
from django.contrib.auth import get_user_model
normal_user = get_user_model().objects.create_user(
email='me@example.com',
name='My Name',
password='MyPassword'
)
superuser = get_user_model().objects.create_superuser(
email='admin@example.com',
name='Super Name',
password='MySuperPassword'
)
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.
Attributes
The EmailUser model has the following attributes:
The email address used as the login username.
- name
A single field for the name of the user.
- password
The password is hashed as set by the django settings.
- is_superuser
A boolean attribute that can only be set programatically.
- is_staff
A boolean attribute that can be set by the admin site or programatically.
EmailUser also subclasses django.contrib.auth.models.PermissionsMixin.
Metadata
Release files for djangorestframework_emailuser 0.3.1.dev0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| djangorestframework_emailuser-0.3.1.dev0.tar.gz | 8.0 kB | Without provenance | Details for djangorestframework_emailuser-0.3.1.dev0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| djangorestframework_emailuser-0.3.1.dev0-py3-none-any.whl | Python 3 | none | any | Details for djangorestframework_emailuser-0.3.1.dev0-py3-none-any.whl |
Total release size: 16.6 kB
Release files / djangorestframework_emailuser-0.3.1.dev0.tar.gz
| Download URL | djangorestframework_emailuser-0.3.1.dev0.tar.gz |
|---|---|
| Size | 8.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
d1e3ac00711d11e17575a19c1d3d2e2ca86e62f83c90100fa6c8f1f7455fd23e
|
|
BLAKE2b-256 checksum How to use checksums |
4d0ea7e4377d691661c9c9ec3252e291a33c9a28782da4d50f50602541ba866d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
python-requests/2.31.0
|
Release files / djangorestframework_emailuser-0.3.1.dev0-py3-none-any.whl
| Download URL | djangorestframework_emailuser-0.3.1.dev0-py3-none-any.whl |
|---|---|
| Size | 8.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
ac06df2088a3af660eade2e464165892351d4158640ea81fdf143b2d54ab15b9
|
|
BLAKE2b-256 checksum How to use checksums |
46275b8e3e5bec047087c51eadbab70f3444091735c57e3c96c5efc02b14f8bd
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
python-requests/2.31.0
|
Security for djangorestframework_emailuser 0.3.1.dev0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.