[Python-modules-commits] [djoser] 01/06: Import djoser_0.5.1.orig.tar.gz
Michael Fladischer
fladi at moszumanska.debian.org
Tue Sep 6 08:03:42 UTC 2016
This is an automated email from the git hooks/post-receive script.
fladi pushed a commit to branch master
in repository djoser.
commit cf00f5641b812e073cc5b2f7ccc37213a3b962b7
Author: Michael Fladischer <FladischerMichael at fladi.at>
Date: Tue Sep 6 09:35:37 2016 +0200
Import djoser_0.5.1.orig.tar.gz
---
PKG-INFO | 851 +++++++++++-------------
README.md | 48 +-
djoser.egg-info/PKG-INFO | 851 +++++++++++-------------
djoser.egg-info/SOURCES.txt | 2 +
djoser/constants.py | 1 +
djoser/serializers.py | 21 +-
djoser/settings.py | 3 +
djoser/templates/confirmation_email_body.txt | 8 +
djoser/templates/confirmation_email_subject.txt | 3 +
djoser/utils.py | 127 ++--
djoser/views.py | 72 +-
setup.py | 2 +-
12 files changed, 983 insertions(+), 1006 deletions(-)
diff --git a/PKG-INFO b/PKG-INFO
index 65177f8..fb78bbb 100644
--- a/PKG-INFO
+++ b/PKG-INFO
@@ -1,743 +1,680 @@
Metadata-Version: 1.1
Name: djoser
-Version: 0.5.0
+Version: 0.5.1
Summary: REST version of Django authentication system.
Home-page: https://github.com/sunscrapers/djoser
Author: SUNSCRAPERS
Author-email: info at sunscrapers.com
License: MIT
-Description: djoser
- ======
+Description: # djoser
- |Build Status| |Coverage Status|
+ [![Build Status](https://travis-ci.org/sunscrapers/djoser.svg?branch=master)](https://travis-ci.org/sunscrapers/djoser)
+ [![Coverage Status](https://coveralls.io/repos/sunscrapers/djoser/badge.png?branch=master)](https://coveralls.io/r/sunscrapers/djoser?branch=master)
- REST implementation of `Django <https://www.djangoproject.com/>`__
- authentication system. **Djoser** library provides a set of `Django Rest
- Framework <http://www.django-rest-framework.org/>`__ views to handle
- basic actions such as registration, login, logout, password reset and
- account activation. It works with `custom user
- model <https://docs.djangoproject.com/en/dev/topics/auth/customizing/>`__.
+ REST implementation of [Django](https://www.djangoproject.com/) authentication
+ system. **Djoser** library provides a set of [Django Rest Framework](http://www.django-rest-framework.org/)
+ views to handle basic actions such as registration, login, logout, password
+ reset and account activation. It works with [custom user model](https://docs.djangoproject.com/en/dev/topics/auth/customizing/).
- Instead of reusing Django code (e.g. ``PasswordResetForm``), we
- reimplemented few things to fit better into `Single Page
- App <http://en.wikipedia.org/wiki/Single-page_application>`__
+ Instead of reusing Django code (e.g. `PasswordResetForm`), we reimplemented
+ few things to fit better into [Single Page App](http://en.wikipedia.org/wiki/Single-page_application)
architecture.
- Developed by `SUNSCRAPERS <http://sunscrapers.com/>`__ with passion &
- patience.
+ Developed by [SUNSCRAPERS](http://sunscrapers.com/) with passion & patience.
- Features
- --------
+ ## Features
Here is a list of supported authentication backends:
- - `HTTP Basic
- Auth <http://www.django-rest-framework.org/api-guide/authentication/#basicauthentication>`__
- (Default)
- - `Token based authentication from Django Rest
- Framework <http://www.django-rest-framework.org/api-guide/authentication#tokenauthentication>`__
+ * [HTTP Basic Auth](http://www.django-rest-framework.org/api-guide/authentication/#basicauthentication) (Default)
+ * [Token based authentication from Django Rest Framework](http://www.django-rest-framework.org/api-guide/authentication#tokenauthentication)
Available endpoints:
- - ``/me/``
- - ``/register/``
- - ``/login/`` (token based authentication)
- - ``/logout/`` (token based authentication)
- - ``/activate/``
- - ``/{{ User.USERNAME_FIELD }}/``
- - ``/password/``
- - ``/password/reset/``
- - ``/password/reset/confirm/``
+ * `/me/`
+ * `/register/`
+ * `/login/` (token based authentication)
+ * `/logout/` (token based authentication)
+ * `/activate/`
+ * `/{{ User.USERNAME_FIELD }}/`
+ * `/password/`
+ * `/password/reset/`
+ * `/password/reset/confirm/`
Supported Python versions:
- - Python 2.7
- - Python 3.4
- - Python 3.5
+ * Python 2.7
+ * Python 3.4
+ * Python 3.5
Supported Django versions:
- - Django 1.7
- - Django 1.8
- - Django 1.9
+ * Django 1.7
+ * Django 1.8
+ * Django 1.9
+ * Django 1.10
Supported Django Rest Framework versions:
- - Django Rest Framework 3.x
+ * Django Rest Framework 3.x
- For Django Rest Framework 2.4 support check `djoser
- 0.3.2 <https://github.com/sunscrapers/djoser/tree/0.3.2>`__.
+ For Django Rest Framework 2.4 support check [djoser 0.3.2](https://github.com/sunscrapers/djoser/tree/0.3.2).
- Installation
- ------------
+ ## Installation
- Use ``pip``:
-
- ::
+ Use `pip`:
$ pip install djoser
- Quick Start
- -----------
-
- Configure ``INSTALLED_APPS``:
-
- .. code:: python
-
- INSTALLED_APPS = (
- 'django.contrib.auth',
- (...),
- 'rest_framework',
- 'djoser',
- (...),
- )
-
- Configure ``urls.py``:
+ ## Quick Start
- .. code:: python
+ Configure `INSTALLED_APPS`:
- urlpatterns = patterns('',
- (...),
- url(r'^auth/', include('djoser.urls')),
- )
+ ```python
+ INSTALLED_APPS = (
+ 'django.contrib.auth',
+ (...),
+ 'rest_framework',
+ 'djoser',
+ (...),
+ )
+ ```
- HTTP Basic Auth strategy is assumed by default as Django Rest Framework
- does it. However you may want to set it explicitly:
+ Configure `urls.py`:
- .. code:: python
+ ```python
+ urlpatterns = patterns('',
+ (...),
+ url(r'^auth/', include('djoser.urls')),
+ )
+ ```
- REST_FRAMEWORK = {
- 'DEFAULT_AUTHENTICATION_CLASSES': (
- 'rest_framework.authentication.BasicAuthentication',
- ),
- }
+ HTTP Basic Auth strategy is assumed by default as Django Rest Framework does it. However you may want to set it
+ explicitly:
- Run migrations (if you are using Django 1.7+ or South) - this step will
- create tables for ``auth`` app:
+ ```python
+ REST_FRAMEWORK = {
+ 'DEFAULT_AUTHENTICATION_CLASSES': (
+ 'rest_framework.authentication.BasicAuthentication',
+ ),
+ }
+ ```
- ::
+ Run migrations – this step will create tables for `auth` app:
$ ./manage.py migrate
- Customizing authentication backend
- ----------------------------------
+ ## Customizing authentication backend
- Token Based Authentication
- ~~~~~~~~~~~~~~~~~~~~~~~~~~
+ ### Token Based Authentication
- Add ``'rest_framework.authtoken'`` to ``INSTALLED_APPS``:
+ Add `'rest_framework.authtoken'` to `INSTALLED_APPS`:
- .. code:: python
+ ```python
+ INSTALLED_APPS = (
+ 'django.contrib.auth',
+ (...),
+ 'rest_framework',
+ 'rest_framework.authtoken',
+ 'djoser',
+ (...),
+ )
+ ```
- INSTALLED_APPS = (
- 'django.contrib.auth',
- (...),
- 'rest_framework',
- 'rest_framework.authtoken',
- 'djoser',
- (...),
- )
+ Configure `urls.py`. Pay attention to `djoser.url.authtoken` module path.
- Configure ``urls.py``. Pay attention to ``djoser.url.authtoken`` module
- path.
+ ```python
+ urlpatterns = patterns('',
+ (...),
+ url(r'^auth/', include('djoser.urls.authtoken')),
+ )
+ ```
- .. code:: python
+ Set `TokenAuthentication` as default Django Rest Framework authentication strategy:
- urlpatterns = patterns('',
- (...),
- url(r'^auth/', include('djoser.urls.authtoken')),
- )
+ ```python
+ REST_FRAMEWORK = {
+ 'DEFAULT_AUTHENTICATION_CLASSES': (
+ 'rest_framework.authentication.TokenAuthentication',
+ ),
+ }
+ ```
- Set ``TokenAuthentication`` as default Django Rest Framework
- authentication strategy:
-
- .. code:: python
-
- REST_FRAMEWORK = {
- 'DEFAULT_AUTHENTICATION_CLASSES': (
- 'rest_framework.authentication.TokenAuthentication',
- ),
- }
-
- Run migrations (if you are using Django 1.7+ or South) - this step will
- create tables for ``auth`` and ``authtoken`` apps:
-
- ::
+ Run migrations – this step will create tables for `auth` and `authtoken` apps:
$ ./manage.py migrate
- Settings
- --------
-
- Optionally add ``DJOSER`` settings:
+ ## Settings
- .. code:: python
+ Optionally add `DJOSER` settings:
- DJOSER = {
- 'DOMAIN': 'frontend.com',
- 'SITE_NAME': 'Frontend',
- 'PASSWORD_RESET_CONFIRM_URL': '#/password/reset/confirm/{uid}/{token}',
- 'ACTIVATION_URL': '#/activate/{uid}/{token}',
- 'SEND_ACTIVATION_EMAIL': True,
- 'PASSWORD_VALIDATORS': [],
- 'SERIALIZERS': {},
- }
+ ```python
+ DJOSER = {
+ 'DOMAIN': 'frontend.com',
+ 'SITE_NAME': 'Frontend',
+ 'PASSWORD_RESET_CONFIRM_URL': '#/password/reset/confirm/{uid}/{token}',
+ 'ACTIVATION_URL': '#/activate/{uid}/{token}',
+ 'SEND_ACTIVATION_EMAIL': True,
+ 'PASSWORD_VALIDATORS': [],
+ 'SERIALIZERS': {},
+ }
+ ```
Check "Settings" section for more info.
- Endpoints
- ---------
+ ## Endpoints
- User
- ~~~~
+ ### User
Use this endpoint to retrieve/update user.
- ``GET``
- ^^^^^^^
+ #### `GET`
- URL: ``/me/``
+ URL: `/me/`
Retrieve user.
- - **response**
+ * **response**
- - status: ``HTTP_200_OK`` (success)
+ * status: `HTTP_200_OK` (success)
- - data:
+ * data:
- ``{{ User.USERNAME_FIELD }}``
+ `{{ User.USERNAME_FIELD }}`
- ``{{ User._meta.pk.name }}``
+ `{{ User._meta.pk.name }}`
- ``{{ User.REQUIRED_FIELDS }}``
+ `{{ User.REQUIRED_FIELDS }}`
- ``PUT``
- ^^^^^^^
+ #### `PUT`
- URL: ``/me/``
+ URL: `/me/`
Update user.
- - **request**
+ * **request**
- - data:
+ * data:
- ``{{ User.REQUIRED_FIELDS }}``
+ `{{ User.REQUIRED_FIELDS }}`
- - **response**
+ * **response**
- - status: ``HTTP_200_OK`` (success)
+ * status: `HTTP_200_OK` (success)
- - data:
+ * data:
- ``{{ User.USERNAME_FIELD }}``
+ `{{ User.USERNAME_FIELD }}`
- ``{{ User._meta.pk.name }}``
+ `{{ User._meta.pk.name }}`
- ``{{ User.REQUIRED_FIELDS }}``
+ `{{ User.REQUIRED_FIELDS }}`
- Register
- ~~~~~~~~
+ ### Register
Use this endpoint to register new user. Your user model manager should
- implement
- `create\_user <https://docs.djangoproject.com/en/dev/ref/contrib/auth/#django.contrib.auth.models.UserManager.create_user>`__
- method and have
- `USERNAME\_FIELD <https://docs.djangoproject.com/en/dev/topics/auth/customizing/#django.contrib.auth.models.CustomUser.USERNAME_FIELD>`__
- and
- `REQUIRED\_FIELDS <https://docs.djangoproject.com/en/dev/topics/auth/customizing/#django.contrib.auth.models.CustomUser.REQUIRED_FIELDS>`__
+ implement [create_user](https://docs.djangoproject.com/en/dev/ref/contrib/auth/#django.contrib.auth.models.UserManager.create_user)
+ method and have [USERNAME_FIELD](https://docs.djangoproject.com/en/dev/topics/auth/customizing/#django.contrib.auth.models.CustomUser.USERNAME_FIELD)
+ and [REQUIRED_FIELDS](https://docs.djangoproject.com/en/dev/topics/auth/customizing/#django.contrib.auth.models.CustomUser.REQUIRED_FIELDS)
fields.
- ``POST``
- ^^^^^^^^
+ #### `POST`
- URL: ``/register/``
+ URL: `/register/`
- - **request**
+ * **request**
- - data:
+ * data:
- ``{{ User.USERNAME_FIELD }}``
+ `{{ User.USERNAME_FIELD }}`
- ``{{ User.REQUIRED_FIELDS }}``
+ `{{ User.REQUIRED_FIELDS }}`
- ``password``
+ `password`
- - **response**
+ * **response**
- - status: ``HTTP_201_CREATED`` (success)
+ * status: `HTTP_201_CREATED` (success)
- - data:
+ * data:
- ``{{ User.USERNAME_FIELD }}``
+ `{{ User.USERNAME_FIELD }}`
- ``{{ User._meta.pk.name }}``
+ `{{ User._meta.pk.name }}`
- ``{{ User.REQUIRED_FIELDS }}``
+ `{{ User.REQUIRED_FIELDS }}`
- Login
- ~~~~~
+ ### Login
- Use this endpoint to obtain user `authentication
- token <http://www.django-rest-framework.org/api-guide/authentication#tokenauthentication>`__.
- This endpoint is available only if you are using token based
- authentication.
+ Use this endpoint to obtain user [authentication token](http://www.django-rest-framework.org/api-guide/authentication#tokenauthentication).
+ This endpoint is available only if you are using token based authentication.
- ``POST``
- ^^^^^^^^
+ #### `POST`
- URL: ``/login/``
+ URL: `/login/`
- - **request**
+ * **request**
- - data:
+ * data:
- ``{{ User.USERNAME_FIELD }}``
+ `{{ User.USERNAME_FIELD }}`
- ``password``
+ `password`
- - **response**
+ * **response**
- - status: ``HTTP_200_OK`` (success)
+ * status: `HTTP_200_OK` (success)
- - data:
+ * data:
- ``auth_token``
+ `auth_token`
- Logout
- ~~~~~~
+ ### Logout
- Use this endpoint to logout user (remove user authentication token).
- This endpoint is available only if you are using token based
- authentication.
+ Use this endpoint to logout user (remove user authentication token). This endpoint is available only if you are using
+ token based authentication.
- ``POST``
- ^^^^^^^^
+ #### `POST`
- URL: ``/logout/``
+ URL: `/logout/`
- - **response**
+ * **response**
- - status: ``HTTP_200_OK`` (success)
+ * status: `HTTP_204_NO_CONTENT` (success)
- Activate
- ~~~~~~~~
+ ### Activate
- Use this endpoint to activate user account. This endpoint is not a URL
- which will be directly exposed to your users - you should provide site
- in your frontend application (configured by ``ACTIVATION_URL``) which
- will send ``POST`` request to activate endpoint.
+ Use this endpoint to activate user account. This endpoint is not a URL which
+ will be directly exposed to your users - you should provide site in your
+ frontend application (configured by `ACTIVATION_URL`) which will send `POST`
+ request to activate endpoint.
- ``POST``
- ^^^^^^^^
+ #### `POST`
- URL: ``/activate/``
+ URL: `/activate/`
- - **request**
+ * **request**
- - data:
+ * data:
- ``uid``
+ `uid`
- ``token``
+ `token`
- - **response**
+ * **response**
- - status: ``HTTP_200_OK`` (success)
+ * status: `HTTP_204_NO_CONTENT` (success)
- Set username
- ~~~~~~~~~~~~
+ ### Set username
- Use this endpoint to change user username (``USERNAME_FIELD``).
+ Use this endpoint to change user username (`USERNAME_FIELD`).
- ``POST``
- ^^^^^^^^
+ #### `POST`
- URL: ``/{{ User.USERNAME_FIELD }}/``
+ URL: `/{{ User.USERNAME_FIELD }}/`
- - **request**
+ * **request**
- - data:
+ * data:
- ``new_{{ User.USERNAME_FIELD }}``
+ `new_{{ User.USERNAME_FIELD }}`
- ``re_new_{{ User.USERNAME_FIELD }}`` (if ``SET_USERNAME_RETYPE``
- is ``True``)
+ `re_new_{{ User.USERNAME_FIELD }}` (if `SET_USERNAME_RETYPE` is `True`)
- ``current_password``
+ `current_password`
- - **response**
+ * **response**
- - status: ``HTTP_200_OK`` (success)
+ * status: `HTTP_204_NO_CONTENT` (success)
- Set password
- ~~~~~~~~~~~~
+ ### Set password
Use this endpoint to change user password.
- ``POST``
- ^^^^^^^^
+ #### `POST`
- URL: ``/password/``
+ URL: `/password/`
- - **request**
+ * **request**
- - data:
+ * data:
- ``new_password``
+ `new_password`
- ``re_new_password`` (if ``SET_PASSWORD_RETYPE`` is ``True``)
+ `re_new_password` (if `SET_PASSWORD_RETYPE` is `True`)
- ``current_password``
+ `current_password`
- - **response**
+ * **response**
- - status: ``HTTP_200_OK`` (success)
+ * status: `HTTP_204_NO_CONTENT` (success)
- Reset password
- ~~~~~~~~~~~~~~
+ ### Reset password
- Use this endpoint to send email to user with password reset link. You
- have to setup ``PASSWORD_RESET_CONFIRM_URL``.
+ Use this endpoint to send email to user with password reset link. You have to
+ setup `PASSWORD_RESET_CONFIRM_URL`.
- ``POST``
- ^^^^^^^^
+ #### `POST`
- URL: ``/password/reset/``
+ URL: `/password/reset/`
- - **request**
+ * **request**
- - data:
+ * data:
- ``email``
+ `email`
- - **response**
+ * **response**
- - status: ``HTTP_200_OK`` (success)
+ * status: `HTTP_204_NO_CONTENT` (success), if `PASSWORD_RESET_SHOW_EMAIL_NOT_FOUND` is `False` (default); or
+ * status: `HTTP_400_BAD_REQUEST`, if `PASSWORD_RESET_SHOW_EMAIL_NOT_FOUND` is `True` and `email` does not exists in the database.
- Reset password confirmation
- ~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ ### Reset password confirmation
- Use this endpoint to finish reset password process. This endpoint is not
- a URL which will be directly exposed to your users - you should provide
- site in your frontend application (configured by
- ``PASSWORD_RESET_CONFIRM_URL``) which will send ``POST`` request to
- reset password confirmation endpoint.
+ Use this endpoint to finish reset password process. This endpoint is not a URL
+ which will be directly exposed to your users - you should provide site in your
+ frontend application (configured by `PASSWORD_RESET_CONFIRM_URL`) which
+ will send `POST` request to reset password confirmation endpoint.
- ``POST``
- ^^^^^^^^
+ #### `POST`
- URL: ``/password/reset/confirm/``
+ URL: `/password/reset/confirm/`
- - **request**
+ * **request**
- - data:
+ * data:
- ``uid``
+ `uid`
- ``token``
+ `token`
- ``new_password``
+ `new_password`
- ``re_new_password`` (if ``PASSWORD_RESET_CONFIRM_RETYPE`` is
- ``True``)
+ `re_new_password` (if `PASSWORD_RESET_CONFIRM_RETYPE` is `True`)
- - **response**
+ * **response**
- - status: ``HTTP_200_OK`` (success)
+ * status: `HTTP_204_NO_CONTENT` (success)
- Settings
- --------
+ ## Settings
- DOMAIN
- ~~~~~~
+ ### DOMAIN
- Domain of your frontend app. If not provided, domain of current site
- will be used.
+ Domain of your frontend app. If not provided, domain of current site will be
+ used.
- **Required**: ``False``
+ **Required**: `False`
- SITE\_NAME
- ~~~~~~~~~~
+ ### SITE_NAME
Name of your frontend app. If not provided, name of current site will be
used.
- **Required**: ``False``
+ **Required**: `False`
- PASSWORD\_RESET\_CONFIRM\_URL
- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ ### PASSWORD_RESET_CONFIRM_URL
- URL to your frontend password reset page. It should contain ``{uid}``
- and ``{token}`` placeholders, e.g. ``#/password-reset/{uid}/{token}``.
- You should pass ``uid`` and ``token`` to reset password confirmation
- endpoint.
+ URL to your frontend password reset page. It should contain `{uid}` and
+ `{token}` placeholders, e.g. `#/password-reset/{uid}/{token}`. You should pass
+ `uid` and `token` to reset password confirmation endpoint.
- **Required**: ``True``
+ **Required**: `True`
- SEND\_ACTIVATION\_EMAIL
- ~~~~~~~~~~~~~~~~~~~~~~~
+ ### SEND_ACTIVATION_EMAIL
- If ``True``, register endpoint will send activation email to user.
+ If `True`, register endpoint will send activation email to user.
- **Default**: ``False``
+ **Default**: `False`
- ACTIVATION\_URL
- ~~~~~~~~~~~~~~~
+ ### SEND_CONFIRMATION_EMAIL
- URL to your frontend activation page. It should contain ``{uid}`` and
- ``{token}`` placeholders, e.g. ``#/activate/{uid}/{token}``. You should
- pass ``uid`` and ``token`` to activation endpoint.
+ If `True`, register or activation endpoint will send confirmation email to user.
- **Required**: ``True``
+ **Default**: `False`
- SET\_USERNAME\_RETYPE
- ~~~~~~~~~~~~~~~~~~~~~
+ ### ACTIVATION_URL
- If ``True``, you need to pass ``re_new_{{ User.USERNAME_FIELD }}`` to
- ``/{{ User.USERNAME_FIELD }}/`` endpoint, to validate username equality.
+ URL to your frontend activation page. It should contain `{uid}` and `{token}`
+ placeholders, e.g. `#/activate/{uid}/{token}`. You should pass `uid` and
+ `token` to activation endpoint.
- **Default**: ``False``
+ **Required**: `True`
- SET\_PASSWORD\_RETYPE
- ~~~~~~~~~~~~~~~~~~~~~
+ ### SET_USERNAME_RETYPE
- If ``True``, you need to pass ``re_new_password`` to ``/password/``
- endpoint, to validate password equality.
+ If `True`, you need to pass `re_new_{{ User.USERNAME_FIELD }}` to
+ `/{{ User.USERNAME_FIELD }}/` endpoint, to validate username equality.
- **Default**: ``False``
+ **Default**: `False`
- PASSWORD\_RESET\_CONFIRM\_RETYPE
- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ ### SET_PASSWORD_RETYPE
- If ``True``, you need to pass ``re_new_password`` to
- ``/password/reset/confirm/`` endpoint in order to validate password
- equality.
+ If `True`, you need to pass `re_new_password` to `/password/` endpoint, to
+ validate password equality.
- **Default**: ``False``
+ **Default**: `False`
- PASSWORD\_VALIDATORS
- ~~~~~~~~~~~~~~~~~~~~
+ ### PASSWORD_RESET_CONFIRM_RETYPE
- List containing `REST Framework
- Validator <http://www.django-rest-framework.org/api-guide/validators/>`__
- functions. These validators are run on ``/register/`` and
- ``/password/reset/confirm/``.
+ If `True`, you need to pass `re_new_password` to `/password/reset/confirm/`
+ endpoint in order to validate password equality.
- **Default**: ``[]``
+ **Default**: `False`
- **Example**: ``[my_validator1, my_validator2]``
+ ### LOGOUT_ON_PASSWORD_CHANGE
- SERIALIZERS
- ~~~~~~~~~~~
+ If `True`, setting new password will logout the user.
- This dictionary is used to update the defaults, so by providing, let's
- say, one key, all the others will still be used.
+ **Default**: `False`
- **Examples**
+ ### PASSWORD_RESET_SHOW_EMAIL_NOT_FOUND
+
+ If `True`, posting a non-existent `email` to `/password/reset/` will return
+ a `HTTP_400_BAD_REQUEST` response with an `EMAIL_NOT_FOUND` error message
+ ('User with given email does not exist.').
+
+ If `False` (default), the `/password/reset/` endpoint will always return
+ a `HTTP_204_NO_CONTENT` response.
+
+ Please note that setting this to `True` will expose information whether
+ an email is registered in the system.
- ::
+ **Default**: `False`
- {
- 'user': 'myapp.serializers.SpecialUserSerializer',
- }
+ ### PASSWORD_VALIDATORS
- **Default**:
+ List containing [REST Framework Validator](http://www.django-rest-framework.org/api-guide/validators/) functions.
+ These validators are run on `/register/` and `/password/reset/confirm/`.
- ::
+ **Default**: `[]`
- {
- 'activation': 'djoser.serializers.ActivationSerializer',
- 'login': 'djoser.serializers.LoginSerializer',
- 'password_reset': 'djoser.serializers.PasswordResetSerializer',
- 'password_reset_confirm': 'djoser.serializers.PasswordResetConfirmSerializer',
- 'password_reset_confirm_retype': 'djoser.serializers.PasswordResetConfirmRetypeSerializer',
- 'set_password': 'djoser.serializers.SetPasswordSerializer',
- 'set_password_retype': 'djoser.serializers.SetPasswordRetypeSerializer',
- 'set_username': 'djoser.serializers.SetUsernameSerializer',
- 'set_username_retype': 'djoser.serializers.SetUsernameRetypeSerializer',
- 'user_registration': 'djoser.serializers.UserRegistrationSerializer',
- 'user': 'djoser.serializers.UserSerializer',
- 'token': 'djoser.serializers.TokenSerializer',
- }
+ **Example**: `[my_validator1, my_validator2]`
- Emails
- ------
+ ### SERIALIZERS
+
+ This dictionary is used to update the defaults, so by providing,
+ let's say, one key, all the others will still be used.
+
+ **Examples**
+ ```
+ {
+ 'user': 'myapp.serializers.SpecialUserSerializer',
+ }
+ ```
+
+ **Default**:
+ ```
+ {
+ 'activation': 'djoser.serializers.ActivationSerializer',
+ 'login': 'djoser.serializers.LoginSerializer',
+ 'password_reset': 'djoser.serializers.PasswordResetSerializer',
+ 'password_reset_confirm': 'djoser.serializers.PasswordResetConfirmSerializer',
+ 'password_reset_confirm_retype': 'djoser.serializers.PasswordResetConfirmRetypeSerializer',
+ 'set_password': 'djoser.serializers.SetPasswordSerializer',
+ 'set_password_retype': 'djoser.serializers.SetPasswordRetypeSerializer',
+ 'set_username': 'djoser.serializers.SetUsernameSerializer',
+ 'set_username_retype': 'djoser.serializers.SetUsernameRetypeSerializer',
+ 'user_registration': 'djoser.serializers.UserRegistrationSerializer',
+ 'user': 'djoser.serializers.UserSerializer',
+ 'token': 'djoser.serializers.TokenSerializer',
+ }
+ ```
+
+ ## Emails
There are few email templates which you may want to override:
- - ``activation_email_body.txt``
- - ``activation_email_subject.txt``
- - ``password_reset_email_body.txt``
- - ``password_reset_email_subject.txt``
+ * `activation_email_body.txt`
+ * `activation_email_subject.txt`
+ * `password_reset_email_body.txt`
+ * `password_reset_email_subject.txt`
All of them have following context:
- - ``user``
- - ``domain``
- - ``site_name``
- - ``url``
- - ``uid``
- - ``token``
- - ``protocol``
-
- Sample usage
- ------------
+ * `user`
+ * `domain`
+ * `site_name`
+ * `url`
+ * `uid`
+ * `token`
+ * `protocol`
- We provide a standalone test app for you to start easily, see how
- everything works with basic settings. It might be useful before
- integrating **djoser** into your backend application.
+ ## Sample usage
- In this extremely short tutorial we are going to mimic the simplest
- flow: register user, log in and log out. We will also check resource
- access on each consecutive step. Let's go!
+ We provide a standalone test app for you to start easily, see how everything works with basic settings. It might be useful before integrating **djoser** into your backend application.
- - Clone repository and install **djoser** to your virtualenv:
+ In this extremely short tutorial we are going to mimic the simplest flow: register user, log in and log out. We will also check resource access on each consecutive step. Let's go!
- ``$ git clone git at github.com:sunscrapers/djoser.git``
+ * Clone repository and install **djoser** to your virtualenv:
- ``$ cd djoser``
+ `$ git clone git at github.com:sunscrapers/djoser.git`
- ``$ pip install -e .``
+ `$ cd djoser`
- - Go to the ``testproject`` directory, migrate the database and start
- the development server:
+ `$ pip install -e .`
- ``$ cd testproject``
+ * Go to the `testproject` directory, migrate the database and start the development server:
- ``$ ./manage.py migrate``
+ `$ cd testproject`
- ``$ ./manage.py runserver 8088``
+ `$ ./manage.py migrate`
- - Register a new user:
+ `$ ./manage.py runserver 8088`
- ``$ curl -X POST http://127.0.0.1:8088/auth/register/ --data 'username=djoser&password=djoser'``
+ * Register a new user:
- ``{"email": "", "username": "djoser"}``
+ `$ curl -X POST http://127.0.0.1:8088/auth/register/ --data 'username=djoser&password=djoser'`
- So far, so good. We have just created a new user using REST API.
+ `{"email": "", "username": "djoser", "id":1}`
- - Let's access user's details:
+ So far, so good. We have just created a new user using REST API.
- ``$ curl -X GET http://127.0.0.1:8088/auth/me/``
+ * Let's access user's details:
- ``{"detail": "Authentication credentials were not provided."}``
+ `$ curl -X GET http://127.0.0.1:8088/auth/me/`
- As we can see, we cannot access user profile without logging in.
- Pretty obvious.
+ `{"detail": "Authentication credentials were not provided."}`
- - Let's log in:
+ As we can see, we cannot access user profile without logging in. Pretty obvious.
- ``curl -X POST http://127.0.0.1:8088/auth/login/ --data 'username=djoser&password=djoser'``
+ * Let's log in:
- ``{"auth_token": "b704c9fc3655635646356ac2950269f352ea1139"}``
+ `curl -X POST http://127.0.0.1:8088/auth/login/ --data 'username=djoser&password=djoser'`
... 1887 lines suppressed ...
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/python-modules/packages/djoser.git
More information about the Python-modules-commits
mailing list