mirror of
https://github.com/encode/django-rest-framework.git
synced 2025-08-08 14:24:48 +03:00
review cleanup
This commit is contained in:
parent
24ba3b3743
commit
ba21a1e551
|
@ -18,20 +18,17 @@ class AuthTokenSerializer(serializers.Serializer):
|
|||
if user:
|
||||
if not user.is_active:
|
||||
msg = _('User account is disabled.')
|
||||
raise serializers.ValidationError(
|
||||
msg,
|
||||
code='authorization')
|
||||
code = 'authorization'
|
||||
raise serializers.ValidationError(msg, code=code)
|
||||
else:
|
||||
msg = _('Unable to log in with provided credentials.')
|
||||
raise serializers.ValidationError(
|
||||
msg,
|
||||
code='authorization')
|
||||
code = 'authorization'
|
||||
raise serializers.ValidationError(msg, code=code)
|
||||
|
||||
else:
|
||||
msg = _('Must include "username" and "password".')
|
||||
raise serializers.ValidationError(
|
||||
msg,
|
||||
code='authorization')
|
||||
code = 'authorization'
|
||||
raise serializers.ValidationError(msg, code=code)
|
||||
|
||||
attrs['user'] = user
|
||||
return attrs
|
||||
|
|
|
@ -31,9 +31,7 @@ from rest_framework.compat import (
|
|||
MinValueValidator, duration_string, parse_duration, unicode_repr,
|
||||
unicode_to_repr
|
||||
)
|
||||
from rest_framework.exceptions import (
|
||||
ValidationError
|
||||
)
|
||||
from rest_framework.exceptions import ValidationError
|
||||
from rest_framework.settings import api_settings
|
||||
from rest_framework.utils import html, humanize_datetime, representation
|
||||
|
||||
|
|
|
@ -147,9 +147,9 @@ class UniqueTogetherValidator(object):
|
|||
]
|
||||
if None not in checked_values and queryset.exists():
|
||||
field_names = ', '.join(self.fields)
|
||||
raise ValidationError(
|
||||
self.message.format(field_names=field_names),
|
||||
code='unique')
|
||||
message = self.message.format(field_names=field_names)
|
||||
code = 'unique'
|
||||
raise ValidationError(message, code=code)
|
||||
|
||||
def __repr__(self):
|
||||
return unicode_to_repr('<%s(queryset=%s, fields=%s)>' % (
|
||||
|
|
Loading…
Reference in New Issue
Block a user