mirror of
https://github.com/encode/django-rest-framework.git
synced 2024-11-14 05:36:50 +03:00
Mark strings in AuthTokenSerializer as translatable
This commit is contained in:
parent
5333a93126
commit
c15dab903d
|
@ -1,4 +1,6 @@
|
||||||
from django.contrib.auth import authenticate
|
from django.contrib.auth import authenticate
|
||||||
|
from django.utils.translation import ugettext_lazy as _
|
||||||
|
|
||||||
from rest_framework import serializers
|
from rest_framework import serializers
|
||||||
|
|
||||||
|
|
||||||
|
@ -15,10 +17,13 @@ class AuthTokenSerializer(serializers.Serializer):
|
||||||
|
|
||||||
if user:
|
if user:
|
||||||
if not user.is_active:
|
if not user.is_active:
|
||||||
raise serializers.ValidationError('User account is disabled.')
|
msg = _('User account is disabled.')
|
||||||
|
raise serializers.ValidationError()
|
||||||
attrs['user'] = user
|
attrs['user'] = user
|
||||||
return attrs
|
return attrs
|
||||||
else:
|
else:
|
||||||
raise serializers.ValidationError('Unable to login with provided credentials.')
|
msg = _('Unable to login with provided credentials.')
|
||||||
|
raise serializers.ValidationError(msg)
|
||||||
else:
|
else:
|
||||||
raise serializers.ValidationError('Must include "username" and "password"')
|
msg = _('Must include "username" and "password"')
|
||||||
|
raise serializers.ValidationError(msg)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user