本文整理匯總了Python中wagtail.contrib.settings.models.BaseSetting方法的典型用法代碼示例。如果您正苦於以下問題:Python models.BaseSetting方法的具體用法?Python models.BaseSetting怎麽用?Python models.BaseSetting使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類wagtail.contrib.settings.models
的用法示例。
在下文中一共展示了models.BaseSetting方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: _add_setting
# 需要導入模塊: from wagtail.contrib.settings import models [as 別名]
# 或者: from wagtail.contrib.settings.models import BaseSetting [as 別名]
def _add_setting(cls: Type[BaseSetting], node: str, dict_params: dict) -> Type[DjangoObjectType]:
if not hasattr(cls, 'name'): # we always need a name field
cls.name = cls.__name__
dict_params['Meta'].interfaces += (Settings,)
tp = type(node, (DjangoObjectType,), dict_params) # type: Type[DjangoObjectType]
registry.settings[node] = (tp, cls)
return tp
示例2: _register_model
# 需要導入模塊: from wagtail.contrib.settings import models [as 別名]
# 或者: from wagtail.contrib.settings.models import BaseSetting [as 別名]
def _register_model(registered: Set[type], cls: type, snippet: bool,
app: str, prefix: str, override_name=None) -> None:
if cls in registered:
return
prefix = prefix.format(app=string.capwords(app),
cls=cls.__name__)
node = override_name or prefix + cls.__name__
# dict parameters to create GraphQL type
class Meta:
model = cls
interfaces = (graphene.relay.Node, ) if RELAY else tuple()
dict_params = {'Meta': Meta}
# add streamfield handlers
_add_streamfields(cls, node, dict_params, app, prefix)
if snippet:
_add_snippet(cls, node, dict_params)
elif issubclass(cls, AbstractForm):
_add_form(cls, node, dict_params)
elif issubclass(cls, wagtailPage):
_add_page(cls, node, dict_params)
elif issubclass(cls, BaseSetting):
_add_setting(cls, node, dict_params)
else: # Django Model
_add_django_model(cls, node, dict_params)
registered.add(cls)