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


Python admin.VersionAdmin方法代碼示例

本文整理匯總了Python中reversion.admin.VersionAdmin方法的典型用法代碼示例。如果您正苦於以下問題:Python admin.VersionAdmin方法的具體用法?Python admin.VersionAdmin怎麽用?Python admin.VersionAdmin使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在reversion.admin的用法示例。


在下文中一共展示了admin.VersionAdmin方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: patch_admin

# 需要導入模塊: from reversion import admin [as 別名]
# 或者: from reversion.admin import VersionAdmin [as 別名]
def patch_admin(model, admin_site=None):
    """
    Enables version control with full admin integration for a model that has
    already been registered with the django admin site.
    
    This is excellent for adding version control to existing Django contrib
    applications. 
    """
    admin_site = admin_site or admin.site
    try:
        ModelAdmin = admin_site._registry[model].__class__
    except KeyError:
        raise NotRegistered("The model {model} has not been registered with the admin site.".format(
            model = model,
        ))
    # Unregister existing admin class.
    admin_site.unregister(model)
    # Register patched admin class.
    class PatchedModelAdmin(VersionAdmin, ModelAdmin):
        pass
    admin_site.register(model, PatchedModelAdmin)


# Patch generation methods, only available if the google-diff-match-patch
# library is installed.
#
# http://code.google.com/p/google-diff-match-patch/ 
開發者ID:osess,項目名稱:mes,代碼行數:29,代碼來源:helpers.py


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