utils.safestring.SafeText

class SafeText [source] A str (in Python 3) or unicode (in Python 2) subclass that has been specifically marked as “safe” for HTML output purposes.

utils.safestring.SafeString

class SafeString A str subclass that has been specifically marked as “safe” (requires no further escaping) for HTML output purposes. This is SafeBytes on Python 2 and SafeText on Python 3.

utils.safestring.SafeBytes

class SafeBytes [source] A bytes subclass that has been specifically marked as “safe” (requires no further escaping) for HTML output purposes.

utils.safestring.mark_safe()

mark_safe(s) [source] Explicitly mark a string as safe for (HTML) output purposes. The returned object can be used everywhere a string or unicode object is appropriate. Can be called multiple times on a single string. For building up fragments of HTML, you should normally be using django.utils.html.format_html() instead. String marked safe will become unsafe again if modified. For example: >>> mystr = '<b>Hello World</b> ' >>> mystr = mark_safe(mystr) >>

utils.safestring.mark_for_escaping()

mark_for_escaping(s) [source] Deprecated since version 1.10. Explicitly mark a string as requiring HTML escaping upon output. Has no effect on SafeData subclasses. Can be called multiple times on a single string (the resulting escaping is only applied once).

utils.module_loading.import_string()

import_string(dotted_path) [source] Imports a dotted module path and returns the attribute/class designated by the last name in the path. Raises ImportError if the import failed. For example: from django.utils.module_loading import import_string ValidationError = import_string('django.core.exceptions.ValidationError') is equivalent to: from django.core.exceptions import ValidationError

utils.log.RequireDebugTrue

class RequireDebugTrue [source] This filter is similar to RequireDebugFalse, except that records are passed only when DEBUG is True.

utils.log.RequireDebugFalse

class RequireDebugFalse [source] This filter will only pass on records when settings.DEBUG is False. This filter is used as follows in the default LOGGING configuration to ensure that the AdminEmailHandler only sends error emails to admins when DEBUG is False: 'filters': { 'require_debug_false': { '()': 'django.utils.log.RequireDebugFalse', } }, 'handlers': { 'mail_admins': { 'level': 'ERROR', 'filters': ['require_debug_false'], 'class': 'django.ut

utils.log.CallbackFilter

class CallbackFilter(callback) [source] This filter accepts a callback function (which should accept a single argument, the record to be logged), and calls it for each record that passes through the filter. Handling of that record will not proceed if the callback returns False. For instance, to filter out UnreadablePostError (raised when a user cancels an upload) from the admin emails, you would create a filter function: from django.http import UnreadablePostError def skip_unreadable_post(r

utils.log.AdminEmailHandler.send_mail()

send_mail(subject, message, *args, **kwargs) [source] Sends emails to admin users. To customize this behavior, you can subclass the AdminEmailHandler class and override this method.