本文整理匯總了Python中django.contrib.messages.utils.get_level_tags方法的典型用法代碼示例。如果您正苦於以下問題:Python utils.get_level_tags方法的具體用法?Python utils.get_level_tags怎麽用?Python utils.get_level_tags使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類django.contrib.messages.utils
的用法示例。
在下文中一共展示了utils.get_level_tags方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: enable
# 需要導入模塊: from django.contrib.messages import utils [as 別名]
# 或者: from django.contrib.messages.utils import get_level_tags [as 別名]
def enable(self):
super().enable()
# LEVEL_TAGS is a constant defined in the
# django.contrib.messages.storage.base module, so after changing
# settings.MESSAGE_TAGS, update that constant also.
self.old_level_tags = base.LEVEL_TAGS
base.LEVEL_TAGS = utils.get_level_tags()
示例2: styleguide
# 需要導入模塊: from django.contrib.messages import utils [as 別名]
# 或者: from django.contrib.messages.utils import get_level_tags [as 別名]
def styleguide(request):
now = timezone.now() + timedelta(-1)
domain = mock.Mock(domain="example.com")
# create a bunch of mocked inboxes
inboxes = [
mock.Mock(
inbox="qwerty",
domain=domain,
get_bools_for_labels=(("new", False),),
last_activity=now,
form=InboxEditForm(request),
),
mock.Mock(
inbox="qwerty",
domain=domain,
get_bools_for_labels=(("disabled", True),),
last_activity=now,
form=False,
),
mock.Mock(
inbox="qwerty",
domain=domain,
get_bools_for_labels=(("new", True), ("pinned", True)),
last_activity=now,
form=False,
),
]
# emails
emails = [
mock.Mock(
inbox=inboxes[0],
get_bools_for_labels=(("important", True),),
received_date=now,
),
mock.Mock(
inbox=inboxes[0],
get_bools_for_labels=(("important", False),),
received_date=now,
),
]
# attachments
attachments = [
mock.Mock(id=0, filename=("a" * 100), content_type="blah/blah", get_children=[]),
mock.Mock(id=0, filename="a", content_type=None, get_children=[]),
]
context = {
"inboxes": inboxes,
"emails": emails,
"attachments": attachments,
"form": Form(),
"message_types": [(k, get_level_tags()[v]) for k, v in DEFAULT_LEVELS.items() if k != 'DEBUG'],
}
return TemplateResponse(request, 'inboxen/styleguide.html', context)