本文整理汇总了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()