本文整理匯總了Python中django.contrib.messages.constants.DEBUG屬性的典型用法代碼示例。如果您正苦於以下問題:Python constants.DEBUG屬性的具體用法?Python constants.DEBUG怎麽用?Python constants.DEBUG使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在類django.contrib.messages.constants
的用法示例。
在下文中一共展示了constants.DEBUG屬性的11個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: dump_config
# 需要導入模塊: from django.contrib.messages import constants [as 別名]
# 或者: from django.contrib.messages.constants import DEBUG [as 別名]
def dump_config() -> None:
"""Print the configuration in the console."""
print('ALLOWED_HOSTS:', ALLOWED_HOSTS)
print('BASE_DIR:', BASE_DIR())
print('CELERY_TASK_ALWAYS_EAGER:', CELERY_TASK_ALWAYS_EAGER)
print('DATABASE_URL:', DATABASES['default'])
print('DEBUG:', DEBUG)
print('DOMAIN_NAME:', DOMAIN_NAME)
print('MEDIA_ROOT:', MEDIA_ROOT)
print('MEDIA_URL:', MEDIA_URL)
print('ONTASK_HELP_URL:', ONTASK_HELP_URL)
print('ONTASK_TESTING:', ONTASK_TESTING)
print('REDIS_URL:', REDIS_URL)
print('STATICFILES_DIRS:', ', '.join(STATICFILES_DIRS))
print('STATIC_ROOT:', STATIC_ROOT)
print('STATIC_URL:', STATIC_URL)
print('USE_SSL:', USE_SSL)
示例2: debug
# 需要導入模塊: from django.contrib.messages import constants [as 別名]
# 或者: from django.contrib.messages.constants import DEBUG [as 別名]
def debug(request, message, extra_tags='', fail_silently=False):
"""
Adds a message with the ``DEBUG`` level.
"""
add_message(request, constants.DEBUG, message, extra_tags=extra_tags,
fail_silently=fail_silently)
示例3: debug
# 需要導入模塊: from django.contrib.messages import constants [as 別名]
# 或者: from django.contrib.messages.constants import DEBUG [as 別名]
def debug(request, message, extra_tags='', fail_silently=False):
"""Add a message with the ``DEBUG`` level."""
add_message(request, constants.DEBUG, message, extra_tags=extra_tags,
fail_silently=fail_silently)
示例4: debug
# 需要導入模塊: from django.contrib.messages import constants [as 別名]
# 或者: from django.contrib.messages.constants import DEBUG [as 別名]
def debug(user, message):
"""
Adds a message with the ``DEBUG`` level.
:param user: User instance
:param message: Message to show
"""
message_user(user, message, constants.DEBUG)
示例5: add_level_messages
# 需要導入模塊: from django.contrib.messages import constants [as 別名]
# 或者: from django.contrib.messages.constants import DEBUG [as 別名]
def add_level_messages(storage):
"""
Add 6 messages from different levels (including a custom one) to a storage
instance.
"""
storage.add(constants.INFO, 'A generic info message')
storage.add(29, 'Some custom level')
storage.add(constants.DEBUG, 'A debugging message', extra_tags='extra-tag')
storage.add(constants.WARNING, 'A warning')
storage.add(constants.ERROR, 'An error')
storage.add(constants.SUCCESS, 'This was a triumph.')
示例6: test_safedata
# 需要導入模塊: from django.contrib.messages import constants [as 別名]
# 或者: from django.contrib.messages.constants import DEBUG [as 別名]
def test_safedata(self):
"""
A message containing SafeData is keeping its safe status when
retrieved from the message storage.
"""
def encode_decode(data):
message = Message(constants.DEBUG, data)
encoded = storage._encode(message)
decoded = storage._decode(encoded)
return decoded.message
storage = self.get_storage()
self.assertIsInstance(encode_decode(mark_safe("<b>Hello Django!</b>")), SafeData)
self.assertNotIsInstance(encode_decode("<b>Hello Django!</b>"), SafeData)
示例7: test_safedata
# 需要導入模塊: from django.contrib.messages import constants [as 別名]
# 或者: from django.contrib.messages.constants import DEBUG [as 別名]
def test_safedata(self):
"""
A message containing SafeData keeps its safe status when retrieved from
the message storage.
"""
storage = self.get_storage()
message = Message(constants.DEBUG, mark_safe("<b>Hello Django!</b>"))
set_session_data(storage, [message])
self.assertIsInstance(list(storage)[0].message, SafeData)
示例8: debug
# 需要導入模塊: from django.contrib.messages import constants [as 別名]
# 或者: from django.contrib.messages.constants import DEBUG [as 別名]
def debug(self, msg):
self.add_message(constants.DEBUG, msg)
示例9: debug
# 需要導入模塊: from django.contrib.messages import constants [as 別名]
# 或者: from django.contrib.messages.constants import DEBUG [as 別名]
def debug(request, message, extra_tags='', fail_silently=False):
"""Adds a message with the ``DEBUG`` level."""
add_message(request, constants.DEBUG, message, extra_tags=extra_tags,
fail_silently=fail_silently)
示例10: level_to_bootstrap
# 需要導入模塊: from django.contrib.messages import constants [as 別名]
# 或者: from django.contrib.messages.constants import DEBUG [as 別名]
def level_to_bootstrap(message):
map = {
constants.DEBUG: 'alert-info',
constants.INFO: 'alert-info',
constants.SUCCESS: 'alert-success',
constants.WARNING: 'alert-warning',
constants.ERROR: 'alert-danger',
}
return map.get(message.level, 'alert-info')
示例11: post_setup
# 需要導入模塊: from django.contrib.messages import constants [as 別名]
# 或者: from django.contrib.messages.constants import DEBUG [as 別名]
def post_setup(cls):
"""Check database setup after settings are loaded"""
# super(Base, cls).post_setup()
if cls.DATABASES['default']['ENGINE'] == 'django.db.backends.mysql':
# Force strict mode (MySQL only)
# https://stackoverflow.com/questions/23022858/force-strict-sql-mode-in-django
if 'OPTIONS' not in cls.DATABASES['default']:
cls.DATABASES['default']['OPTIONS'] = {}
cls.DATABASES['default']['OPTIONS']['sql_mode'] = 'traditional'
# TODO Check this to handle "Incorrect string value" db error
# cls.DATABASES['default']['OPTIONS']['charset'] = 'utf8mb4'
cls.DATABASE_MYSQL = True
else:
cls.DATABASE_MYSQL = False
# Disable cache
if cls.DEBUG and cls.CACHE_DISABLE:
cls.CACHES['default']['BACKEND'] = 'django.core.cache.backends.dummy.DummyCache'
# Overwrite log filename
log_file = values.Value(default=None, environ_name='LOG_FILE')
if 'handlers' in cls.LOGGING and 'logfile' in cls.LOGGING['handlers'] and log_file:
cls.LOGGING['handlers']['logfile']['filename'] = os.path.join(cls.BASE_DIR, 'logs', log_file)