User registration base on Django Rest Framework.
Check the document at https://drf-registration.readthedocs.io/
- Django (>=2.0)
- Django REST Framework (>=3.8.2)
- Python (>=3.6)
- Register
- Verify/activate account by token sent to email
- Login use token
- Logout
- User profile
- Change password
- Reset password
- Login by socials (Facebook, Google)
- Set password when login by social
- Sync user account with socials
- HTML email configuration
- Test coverage (98%)
Assuming that base resource is /api/v1/accounts/
Register new user
Verify account by email
Login to the system use username/email and password
Logout of the system
Get user profile
Update user profile
Change user password
Set user password when login with social account
- Install by use
pip
:
pip install drf-regisration
- Add
drf_registration
inINSTALLED_APPS
INSTALLED_APPS = [
...
'rest_framework',
'rest_framework.authtoken',
'drf_registration',
...
]
- Include urls of
drf_registration
inurls.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,]
.
- Set
DEFAULT_AUTHENTICATION_CLASSES
inREST_FRAMEWORK
configuration
REST_FRAMEWORK = {
'DEFAULT_AUTHENTICATION_CLASSES': [
'rest_framework.authentication.TokenAuthentication',
],
}
DRF_REGISTRATION = {
}
- 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