本文整理汇总了Python中django.contrib.messages.storage.default_storage方法的典型用法代码示例。如果您正苦于以下问题:Python storage.default_storage方法的具体用法?Python storage.default_storage怎么用?Python storage.default_storage使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类django.contrib.messages.storage
的用法示例。
在下文中一共展示了storage.default_storage方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get_level
# 需要导入模块: from django.contrib.messages import storage [as 别名]
# 或者: from django.contrib.messages.storage import default_storage [as 别名]
def get_level(request):
"""
Returns the minimum level of messages to be recorded.
The default level is the ``MESSAGE_LEVEL`` setting. If this is not found,
the ``INFO`` level is used.
"""
if hasattr(request, '_messages'):
storage = request._messages
else:
storage = default_storage(request)
return storage.level
示例2: process_request
# 需要导入模块: from django.contrib.messages import storage [as 别名]
# 或者: from django.contrib.messages.storage import default_storage [as 别名]
def process_request(self, request):
request._messages = default_storage(request)
示例3: get_level
# 需要导入模块: from django.contrib.messages import storage [as 别名]
# 或者: from django.contrib.messages.storage import default_storage [as 别名]
def get_level(request):
"""
Returns the minimum level of messages to be recorded.
The default level is the ``MESSAGE_LEVEL`` setting. If this is not found,
the ``INFO`` level is used.
"""
storage = getattr(request, '_messages', default_storage(request))
return storage.level
示例4: _post_request
# 需要导入模块: from django.contrib.messages import storage [as 别名]
# 或者: from django.contrib.messages.storage import default_storage [as 别名]
def _post_request(self, user):
data = {
'plugin_type': 'TextPlugin',
'placeholder_id': self._placeholder.pk,
'plugin_language': 'en',
}
request = self.get_post_request(data)
request.user = self.reload(user)
request._messages = default_storage(request)
return request
示例5: test_create_message_mixin
# 需要导入模块: from django.contrib.messages import storage [as 别名]
# 或者: from django.contrib.messages.storage import default_storage [as 别名]
def test_create_message_mixin(self):
request = self.factory.post('/fake-path', {
'username': 'gclooney',
'email': '[email protected]',
})
request._messages = default_storage(request)
CreateMessageView.as_view()(request)
self.assertEqual(len(get_messages(request)), 1)
示例6: test_update_message_mixin
# 需要导入模块: from django.contrib.messages import storage [as 别名]
# 或者: from django.contrib.messages.storage import default_storage [as 别名]
def test_update_message_mixin(self):
request = self.factory.post('/fake-path', {
'username': 'gclooney',
'email': '[email protected]',
})
request._messages = default_storage(request)
UpdateMessageView.as_view()(request)
self.assertEqual(len(get_messages(request)), 1)
示例7: test_delete_message_mixin
# 需要导入模块: from django.contrib.messages import storage [as 别名]
# 或者: from django.contrib.messages.storage import default_storage [as 别名]
def test_delete_message_mixin(self):
request = self.factory.post('/fake-path', {})
request._messages = default_storage(request)
DeleteMessageView.as_view()(request)
self.assertEqual(len(get_messages(request)), 1)