本文整理匯總了Python中xadmin.util.model_ngettext方法的典型用法代碼示例。如果您正苦於以下問題:Python util.model_ngettext方法的具體用法?Python util.model_ngettext怎麽用?Python util.model_ngettext使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類xadmin.util
的用法示例。
在下文中一共展示了util.model_ngettext方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: change_models
# 需要導入模塊: from xadmin import util [as 別名]
# 或者: from xadmin.util import model_ngettext [as 別名]
def change_models(self, queryset, cleaned_data):
n = queryset.count()
data = {}
fields = self.opts.fields + self.opts.many_to_many
for f in fields:
if not f.editable or isinstance(f, models.AutoField) \
or not f.name in cleaned_data:
continue
data[f] = cleaned_data[f.name]
if n:
for obj in queryset:
for f, v in data.items():
f.save_form_data(obj, v)
obj.save()
self.message_user(_("Successfully change %(count)d %(items)s.") % {
"count": n, "items": model_ngettext(self.opts, n)
}, 'success')
示例2: change_models
# 需要導入模塊: from xadmin import util [as 別名]
# 或者: from xadmin.util import model_ngettext [as 別名]
def change_models(self, queryset, cleaned_data):
n = queryset.count()
data = {}
for f in self.opts.fields:
if not f.editable or isinstance(f, models.AutoField) \
or not f.name in cleaned_data:
continue
data[f] = cleaned_data[f.name]
if n:
for obj in queryset:
for f, v in data.items():
f.save_form_data(obj, v)
obj.save()
self.message_user(_("Successfully change %(count)d %(items)s.") % {
"count": n, "items": model_ngettext(self.opts, n)
}, 'success')
示例3: delete_models
# 需要導入模塊: from xadmin import util [as 別名]
# 或者: from xadmin.util import model_ngettext [as 別名]
def delete_models(self, queryset):
n = queryset.count()
if n:
if self.delete_models_batch:
self.log('delete', _('Batch delete %(count)d %(items)s.') % { "count": n, "items": model_ngettext(self.opts, n) })
queryset.delete()
else:
for obj in queryset:
self.log('delete', '', obj)
obj.delete()
self.message_user(_("Successfully deleted %(count)d %(items)s.") % {
"count": n, "items": model_ngettext(self.opts, n)
}, 'success')
示例4: delete_models
# 需要導入模塊: from xadmin import util [as 別名]
# 或者: from xadmin.util import model_ngettext [as 別名]
def delete_models(self, queryset):
n = queryset.count()
if n:
if self.delete_models_batch:
self.log('delete', _('Batch delete %(count)d %(items)s.') % {"count": n, "items": model_ngettext(self.opts, n)})
queryset.delete()
else:
for obj in queryset:
self.log('delete', '', obj)
obj.delete()
self.message_user(_("Successfully deleted %(count)d %(items)s.") % {
"count": n, "items": model_ngettext(self.opts, n)
}, 'success')
示例5: delete_models
# 需要導入模塊: from xadmin import util [as 別名]
# 或者: from xadmin.util import model_ngettext [as 別名]
def delete_models(self, queryset):
n = queryset.count()
if n:
if self.delete_models_batch:
queryset.delete()
else:
for obj in queryset:
obj.delete()
self.message_user(_("Successfully deleted %(count)d %(items)s.") % {
"count": n, "items": model_ngettext(self.opts, n)
}, 'success')