當前位置: 首頁>>代碼示例>>Python>>正文


Python util.model_ngettext方法代碼示例

本文整理匯總了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') 
開發者ID:stormsha,項目名稱:StormOnline,代碼行數:21,代碼來源:batch.py

示例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') 
開發者ID:madre,項目名稱:devops,代碼行數:20,代碼來源:batch.py

示例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') 
開發者ID:stormsha,項目名稱:StormOnline,代碼行數:15,代碼來源:actions.py

示例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') 
開發者ID:Superbsco,項目名稱:weibo-analysis-system,代碼行數:15,代碼來源:actions.py

示例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') 
開發者ID:madre,項目名稱:devops,代碼行數:13,代碼來源:actions.py


注:本文中的xadmin.util.model_ngettext方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。