Simple user registration package based on Django Rest Framework. DRF Registration - The easy way to generate registration RESTful APIs.
Check the document at https://drf-registration.readthedocs.io/
Install by use pip
:
pip install drf-registration
Add drf_registration
in INSTALLED_APPS
INSTALLED_APPS = [
...
'rest_framework',
'rest_framework.authtoken',
'drf_registration',
...
]
Include urls of drf_registration
in urls.py
urlpatterns = [
...
path('/api/accounts/', include('drf_registration.urls')),
...
]
Set AUTHENTICATION_BACKEND
for support login by multiple custom fields and check inactivate user when login:
AUTHENTICATION_BACKENDS = [
'drf_registration.auth.MultiFieldsModelBackend',
]
You can update login username fields by change LOGIN_USERNAME_FIELDS
in DRF_REGISTRATION
object. Default to ['username', 'email',]
.
DEFAULT_AUTHENTICATION_CLASSES
in REST_FRAMEWORK
configurationREST_FRAMEWORK = {
'DEFAULT_AUTHENTICATION_CLASSES': [
'rest_framework.authentication.TokenAuthentication',
],
}
DRF_REGISTRATION = {
}
Check default settings here.
Assuming that base resource is /api/v1/accounts/
POST: /register/
: Register new userPOST: /verify/
: Verify account by emailPOST: /login/
: Login to the system use username/email and passwordPOST: /logout/
: Logout of the systemGET: /profile/
: Get user profilePUT: /profile/
: Update user profilePUT: /change-password/
: Change user passwordPUT: /set-password/
: Set user password when login with social accountCheck more APIs Design at here.
Unit Test
make test
You can add ARGS="specific_folder/"
or ARGS="specific_file.py"
to run specific test cases.
Run pylint
make pylint
Build & run docs local server
make docs
Access docs server at http://localhost:8080
Clean
make clean