本文整理匯總了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()
示例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()