for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
from django.contrib.auth import user_logged_in, user_logged_out
The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:
class SomeClass: def some_method(self): """Do x and return foo."""
If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.
from django.utils.encoding import force_bytes, force_text
from django.utils.http import urlsafe_base64_encode, urlsafe_base64_decode
from djoser.conf import settings
def encode_uid(pk):
pk
(([a-z][a-z0-9_]{2,30})|(_[a-z0-9_]*))$
This check looks for invalid names for a range of different identifiers.
You can set regular expressions to which the identifiers must conform if the defaults do not match your requirements.
If your project includes a Pylint configuration file, the settings contained in that file take precedence.
To find out more about Pylint, please refer to their site.
return urlsafe_base64_encode(force_bytes(pk)).decode()
def decode_uid(pk):
return force_text(urlsafe_base64_decode(pk))
def login_user(request, user):
token, _ = settings.TOKEN_MODEL.objects.get_or_create(user=user)
user_logged_in.send(sender=user.__class__, request=request, user=user)
return token
def logout_user(request):
settings.TOKEN_MODEL.objects.filter(user=request.user).delete()
user_logged_out.send(
sender=request.user.__class__, request=request, user=request.user
)
class ActionViewMixin(object):
def post(self, request):
serializer = self.get_serializer(data=request.data)
serializer.is_valid(raise_exception=True)
return self._action(serializer)
The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:
If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.