utils.http.urlquote_plus()

urlquote_plus(url, safe='') [source] A version of Python’s urllib.quote_plus() function that can operate on unicode strings. The url is first UTF-8 encoded before quoting. The returned string can safely be used as part of an argument to a subsequent iri_to_uri() call without double-quoting occurring. Employs lazy execution.

utils.http.urlsafe_base64_decode()

urlsafe_base64_decode(s) [source] Decodes a base64 encoded string, adding back any trailing equal signs that might have been stripped.

utils.http.urlsafe_base64_encode()

urlsafe_base64_encode(s) [source] Encodes a bytestring in base64 for use in URLs, stripping any trailing equal signs.

utils.log.AdminEmailHandler

class AdminEmailHandler(include_html=False, email_backend=None) [source] This handler sends an email to the site admins for each log message it receives. If the log record contains a request attribute, the full details of the request will be included in the email. The email subject will include the phrase “internal IP” if the client’s IP address is in the INTERNAL_IPS setting; if not, it will include “EXTERNAL IP”. If the log record contains stack trace information, that stack trace will be

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.

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.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.RequireDebugTrue

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

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.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).