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


Python Group.id方法代碼示例

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


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

示例1: create_default_group

# 需要導入模塊: from tendenci.apps.user_groups.models import Group [as 別名]
# 或者: from tendenci.apps.user_groups.models.Group import id [as 別名]
def create_default_group(sender, app, **kwargs):
    """
    Auto-create a default group with id=1 if none exist.
    """
    if app == "user_groups":
        if not Group.objects.filter(pk=1):
            site_name = "Default"
            table_exists = Setting._meta.db_table in \
                connection.introspection.table_names()
            if table_exists and get_setting("site", "global", "sitedisplayname"):
                site_name = get_setting("site", "global", "sitedisplayname")

            group = Group()
            group.name = site_name
            group.label = site_name
            group.show_as_option = False
            group.allow_self_add = False
            group.allow_self_remove = False
            group.description = "Initial group auto-generated on site creation."
            group.id = 1

            group.save()
開發者ID:repos-python,項目名稱:tendenci,代碼行數:24,代碼來源:__init__.py

示例2: create_default_group

# 需要導入模塊: from tendenci.apps.user_groups.models import Group [as 別名]
# 或者: from tendenci.apps.user_groups.models.Group import id [as 別名]
def create_default_group(sender, app, **kwargs):
    """
    Load default groups if none exist
    or create a group with id=1 if not exist.
    """
    def get_site_display_name():
        setting_table_exists = Setting._meta.db_table in \
                    connection.introspection.table_names()
        if setting_table_exists:
            return get_setting("site", "global", "sitedisplayname")
        return ''

    if app == "user_groups":
        site_name = get_site_display_name().strip()
        if not Group.objects.all():
            call_command("loaddata", "default_groups.json")
            if site_name:
                # update the name and label of the first default user group
                group = Group.objects.get(pk=1)
                group.name = site_name
                group.label = site_name
                group.save()
        else:
            if not Group.objects.filter(pk=1):
                if not site_name:
                    site_name = "Default"

                group = Group()
                group.name = site_name
                group.label = site_name
                group.show_as_option = False
                group.allow_self_add = False
                group.allow_self_remove = False
                group.description = "Initial group auto-generated on site creation."
                group.id = 1

                group.save()
開發者ID:BillTheBest,項目名稱:tendenci,代碼行數:39,代碼來源:__init__.py


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