Merge pull request #41 from SerhiyRomanov/fix_REST_AUTH_TOKEN_MODEL

Use import_string for getting TokenModel instead of passing class
This commit is contained in:
Michael 2020-04-16 01:56:33 -05:00 committed by GitHub
commit d53c447e95
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 6 deletions

View File

@ -1,6 +1,4 @@
from django.conf import settings
from rest_framework.authtoken.models import Token as DefaultTokenModel
from django.utils.module_loading import import_string
# Register your models here.
TokenModel = getattr(settings, 'REST_AUTH_TOKEN_MODEL', DefaultTokenModel)
TokenModel = import_string(getattr(settings, 'REST_AUTH_TOKEN_MODEL', 'rest_framework.authtoken.models.Token'))

View File

@ -40,9 +40,9 @@ Configuration
.. note:: The custom REGISTER_SERIALIZER must define a ``def save(self, request)`` method that returns a user model instance
- **REST_AUTH_TOKEN_MODEL** - model class for tokens, default value ``rest_framework.authtoken.models``
- **REST_AUTH_TOKEN_MODEL** - path to model class for tokens, default value ``'rest_framework.authtoken.models.Token'``
- **REST_AUTH_TOKEN_CREATOR** - callable to create tokens, default value ``dj_rest_auth.utils.default_create_token``.
- **REST_AUTH_TOKEN_CREATOR** - path to callable or callable for creating tokens, default value ``dj_rest_auth.utils.default_create_token``.
- **REST_SESSION_LOGIN** - Enable session login in Login API view (default: True)