Make 'duplicate_username' message translatable

Added ugettext_lazy and used it on the 'duplicate_username' message
This commit is contained in:
Denis 2018-06-24 02:34:08 +03:00 committed by GitHub
parent ee2bb3f2ef
commit 0d1cfe548c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -3,7 +3,7 @@ from django.contrib import admin
from django.contrib.auth.admin import UserAdmin as AuthUserAdmin
from django.contrib.auth.forms import UserChangeForm, UserCreationForm
from .models import User
from django.utils.translation import ugettext_lazy as _
class MyUserChangeForm(UserChangeForm):
@ -14,7 +14,7 @@ class MyUserChangeForm(UserChangeForm):
class MyUserCreationForm(UserCreationForm):
error_message = UserCreationForm.error_messages.update(
{"duplicate_username": "This username has already been taken."}
{"duplicate_username": _("This username has already been taken.")}
)
class Meta(UserCreationForm.Meta):