debugtools/formatter.py
def pformat_django_context_html(object):
    """
    Dump a variable to a HTML string with sensible output for template context fields.
    It filters out all fields which are not usable in a template context.
    """
    if isinstance(object, QuerySet):
        text = ''
        lineno = 0
        for item in object.all()[:21]:
            lineno += 1
            if lineno >= 21:
                text += u'   (remaining items truncated...)'
                break
            text += u'   {0}\n'.format(escape(repr(item)))
        return text
    elif isinstance(object, Manager):
        return mark_safe(u'    (use <kbd>.all</kbd> to read it)')
    elif isinstance(object, six.string_types):
        return escape(repr(object))
    elif isinstance(object, Promise):
        # lazy() object
        return escape(_format_lazy(object))
    elif isinstance(object, dict):
        # This can also be a ContextDict
        return _format_dict(object)
    elif isinstance(object, list):
        return _format_list(object)
    elif hasattr(object, '__dict__'):
        return _format_object(object)
    else:
        # Use regular pprint as fallback.
        text = DebugPrettyPrinter(width=200).pformat(object)
        return _style_text(text)
def pformat_django_context_html(object):
    if isinstance(object, QuerySet):
        text = ''
        lineno = 0
        for item in object.all()[:21]:
            lineno += 1
            if lineno >= 21:
                text += u'   (remaining items truncated...)'
                break
            text += u'   {0}\n'.format(escape(repr(item)))
        return text
    elif isinstance(object, Manager):
        return mark_safe(u'    (use <kbd>.all</kbd> to read it)')
    elif isinstance(object, six.string_types):
        return escape(repr(object))
    elif isinstance(object, Promise):
        # lazy() object
        return escape(_format_lazy(object))
    elif isinstance(object, dict):
        # This can also be a ContextDict
        return _format_dict(object)
    elif isinstance(object, list):
        return _format_list(object)
    elif hasattr(object, '__dict__'):
        return _format_object(object)
    else:
        # Use regular pprint as fallback.
        text = DebugPrettyPrinter(width=200).pformat(object)
        return _style_text(text)
def pformat_django_context_html ( object ) : if isinstance ( object , QuerySet ) : text = '' lineno = 0 for item in object . all ( ) [ : 21 ] : lineno += 1 if lineno >= 21 : text += u'   (remaining items truncated...)' break text += u'   {0}\n' . format ( escape ( repr ( item ) ) ) return text elif isinstance ( object , Manager ) : return mark_safe ( u'    (use <kbd>.all</kbd> to read it)' ) elif isinstance ( object , six . string_types ) : return escape ( repr ( object ) ) elif isinstance ( object , Promise ) : # lazy() object return escape ( _format_lazy ( object ) ) elif isinstance ( object , dict ) : # This can also be a ContextDict return _format_dict ( object ) elif isinstance ( object , list ) : return _format_list ( object ) elif hasattr ( object , '__dict__' ) : return _format_object ( object ) else : # Use regular pprint as fallback. text = DebugPrettyPrinter ( width = 200 ) . pformat ( object ) return _style_text ( text )
Dump a variable to a HTML string with sensible output for template context fields.
    It filters out all fields which are not usable in a template context.
Dump a variable to a HTML string with sensible output for template context fields . It filters out all fields which are not usable in a template context .