Skip to main content

Django REST Framework - User

User APP for Django REST Framework with API Views.

DRF User is a Django app that overrides default user app to provide additional attributes and functionalities. The current stable version includes:

  • Mobile Number
  • Single field for full name
  • REST API to register
  • REST API to login
  • MultiModelBackend: User can login using either of mobile, email or username
  • REST API to login with OTP (Same API endpoint as for OTP Verification; Set is_login: true while sending JSON request)
  • OTP Verification for mobile and email
  • Mail sending feature upon successful registration
  • SMS sending feature upon successful registration
  • Change Password
  • Update Profile
  • settings.py based configuration
  • Signal based mails: Pending in OTP section
  • Mail based activation (optional alternative for OTP based activation)

Contributors

  • Civil Machines Technologies Private Limited: For providing me platform and funds for research work. This project is hosted currently with CMT only.
  • Himanshu Shankar: The app was initiated and worked upon majorly by Himanshu. This app is currently in use in various other django projects that are developed by him.
  • Aditya Gupta: Aditya has updated view in the app to include additional features such as Change Password. He is also an active contributor in this repository and is working to replace ValidateAndPerformView with appropriate Django REST Framework GenericAPI Views.

** We're looking for someone who can contribute on docs part **

Installation

  • Download and Install via pip
pip install drf_user

or

Download and Install via easy_install

easy_install drf_user
  • Add drf_user in INSTALLED_APPS
INSTALLED_APPS = [
    ...
    'drf_user',
    ...
]
  • Also add other dependencies in INSTALLED_APPS
INSTALLED_APPS = [
    ...
    'drfaddons',
    'rest_framework',
    'django_filters',
    ...
]
  • Include urls of drf_user in urls.py
urlpatterns = [
    ...
    path('api/user/', include('drf_user.urls')),
    ...
]

# or

urlpatterns = [
    ...
    url(r'^api/user/', include('drf_user.urls')),
    ...
]
  • Include AUTH_USER_MODEL in settings.py
...
AUTH_USER_MODEL = 'drf_user.User'
...
  • Finally, run migrate command
python manage.py migrate drf_user

Additional settings

These additional settings are required to use drf_user at its full extent. These settings should be done in settings.py

  • Set AUTHENTICATION_BACKEND:
AUTHENTICATION_BACKENDS = [
    'drf_user.auth.MultiFieldModelBackend',
]
  • Set JWT_PAYLOAD_HANDLER in JWT_AUTH configurations
JWT_AUTH = {
    ...
    'JWT_PAYLOAD_HANDLER': 'drf_user.auth.jwt_payload_handler',
    ...
}
  • Set DEFAULT_AUTHENTICATION_CLASSES in REST_FRAMEWORK configuration
REST_FRAMEWORK = {
    ...
    'DEFAULT_AUTHENTICATION_CLASSES': (
        'drfaddons.auth.JSONWebTokenAuthentication',
        ...
    ),
}

Manual Settings

User can define manual setting in settings.py file in USER_SETTINGS variable . Default options are provided below

user_settings = {
    'DEFAULT_ACTIVE_STATE': False,
    'OTP': {
        'LENGTH': 7,
        'ALLOWED_CHARS': '1234567890',
        'VALIDATION_ATTEMPTS': 3,
        'SUBJECT': 'OTP for Verification',
        'COOLING_PERIOD': 3
    },
    'MOBILE_VALIDATION': True,
    'EMAIL_VALIDATION': True,
    'REGISTRATION': {
        'SEND_MAIL': False,
        'SEND_MESSAGE': False,
        'MAIL_SUBJECT': 'Welcome to DRF-USER',
        'SMS_BODY': 'Your account has been created',
        'TEXT_MAIL_BODY': 'Your account has been created.',
        'HTML_MAIL_BODY': 'Your account has been created.'
    }
}

Metadata

Release files for drf-user 0.0.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for drf-user 0.0.3
File Size Uploaded
drf_user-0.0.3.tar.gz 14.1 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for drf-user 0.0.3
File Interpreter ABI Platform
drf_user-0.0.3-py3-none-any.whl Python 3 none any Details

Total release size: 46.4 kB

Release files / drf_user-0.0.3.tar.gz

Download URL drf_user-0.0.3.tar.gz
Size 14.1 kB
Tags Source
SHA-256 checksum
How to use checksums
0daee663454802239461cce9837e6f13b0fe8234b821cac0ff7f5d1718381b68
BLAKE2b-256 checksum
How to use checksums
210bcecb1780fa93185f7a44f0473d4dfe6d309f94283407e5526cd03551aa11
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.12.1 pkginfo/1.4.2 requests/2.21.0 setuptools/40.5.0 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.6.7

Release files / drf_user-0.0.3-py3-none-any.whl

Download URL drf_user-0.0.3-py3-none-any.whl
Size 32.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
63bb99952c2015bc628b48827e9a959510342c0412c331b344bab6fed2295937
BLAKE2b-256 checksum
How to use checksums
7645ace7a8896c057902f3e362813d020bc2130913d65a69b1cd9801abb308a2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.12.1 pkginfo/1.4.2 requests/2.21.0 setuptools/40.5.0 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.6.7

Release history Release notifications | RSS feed

1.1.0

2 release files

1.0.1

2 release files

1.0.0

2 release files

0.0.8

2 release files

0.0.7

2 release files

0.0.6

2 release files

0.0.5

2 release files

0.0.4

2 release files

This release

0.0.3 This release

2 release files

0.0.2

2 release files

0.0.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page