Skip to content

Commit dce544e

Browse files
committed
Merge pull request #3887 from mnach/enhancement-3886
enhancement #3886 Internationalization in admin interface for authtoken
2 parents d738ad7 + d0f7b04 commit dce544e

File tree

4 files changed

+16
-5
lines changed

4 files changed

+16
-5
lines changed

rest_framework/authtoken/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
default_app_config = 'rest_framework.authtoken.apps.AuthTokenConfig'

rest_framework/authtoken/apps.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
from django.apps import AppConfig
2+
from django.utils.translation import ugettext_lazy as _
3+
4+
5+
class AuthTokenConfig(AppConfig):
6+
name = 'rest_framework.authtoken'
7+
verbose_name = _("Auth Token")

rest_framework/authtoken/models.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
from django.conf import settings
55
from django.db import models
66
from django.utils.encoding import python_2_unicode_compatible
7+
from django.utils.translation import ugettext_lazy as _
78

89
# Prior to Django 1.5, the AUTH_USER_MODEL setting does not exist.
910
# Note that we don't perform this code in the compat module due to
@@ -17,10 +18,10 @@ class Token(models.Model):
1718
"""
1819
The default authorization token model.
1920
"""
20-
key = models.CharField(max_length=40, primary_key=True)
21+
key = models.CharField(_("Key"), max_length=40, primary_key=True)
2122
user = models.OneToOneField(AUTH_USER_MODEL, related_name='auth_token',
22-
on_delete=models.CASCADE)
23-
created = models.DateTimeField(auto_now_add=True)
23+
on_delete=models.CASCADE, verbose_name=_("User"))
24+
created = models.DateTimeField(_("Created"), auto_now_add=True)
2425

2526
class Meta:
2627
# Work around for a bug in Django:
@@ -29,6 +30,8 @@ class Meta:
2930
# Also see corresponding ticket:
3031
# https://github.com/tomchristie/django-rest-framework/issues/705
3132
abstract = 'rest_framework.authtoken' not in settings.INSTALLED_APPS
33+
verbose_name = _("Token")
34+
verbose_name_plural = _("Tokens")
3235

3336
def save(self, *args, **kwargs):
3437
if not self.key:

rest_framework/authtoken/serializers.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55

66

77
class AuthTokenSerializer(serializers.Serializer):
8-
username = serializers.CharField()
9-
password = serializers.CharField(style={'input_type': 'password'})
8+
username = serializers.CharField(label=_("Username"))
9+
password = serializers.CharField(label=_("Password"), style={'input_type': 'password'})
1010

1111
def validate(self, attrs):
1212
username = attrs.get('username')

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy