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