Used model_ngettext in two more places

This commit is contained in:
Claude Paroz 2017-01-30 21:38:55 +01:00
parent dbf79c5acf
commit 3b2e28fc85
2 changed files with 4 additions and 11 deletions

View File

@ -53,10 +53,7 @@ def delete_selected(modeladmin, request, queryset):
# Return None to display the change list page again.
return None
if len(queryset) == 1:
objects_name = force_text(opts.verbose_name)
else:
objects_name = force_text(opts.verbose_name_plural)
objects_name = model_ngettext(queryset)
if perms_needed or protected:
title = _("Cannot delete %(name)s") % {"name": objects_name}

View File

@ -16,8 +16,8 @@ from django.contrib.admin.exceptions import DisallowedModelAdminToField
from django.contrib.admin.templatetags.admin_urls import add_preserved_filters
from django.contrib.admin.utils import (
NestedObjects, construct_change_message, flatten_fieldsets,
get_deleted_objects, lookup_needs_distinct, model_format_dict, quote,
unquote,
get_deleted_objects, lookup_needs_distinct, model_format_dict,
model_ngettext, quote, unquote,
)
from django.contrib.auth import get_permission_codename
from django.core.exceptions import (
@ -1611,17 +1611,13 @@ class ModelAdmin(BaseModelAdmin):
changecount += 1
if changecount:
if changecount == 1:
name = force_text(opts.verbose_name)
else:
name = force_text(opts.verbose_name_plural)
msg = ungettext(
"%(count)s %(name)s was changed successfully.",
"%(count)s %(name)s were changed successfully.",
changecount
) % {
'count': changecount,
'name': name,
'name': model_ngettext(opts, changecount),
'obj': force_text(obj),
}
self.message_user(request, msg, messages.SUCCESS)