(context, model_instance, attribute_name)
return renderer(value, field)
This filter applies all renderers specified in admin2.py to the field.
This filter applies all renderers specified in admin2.py to the field.
This filter applies all renderers specified in admin2 . py to the field .
def render(context, model_instance, attribute_name):
    """
    This filter applies all renderers specified in admin2.py to the field.
    """
    value = utils.get_attr(model_instance, attribute_name)

    # Get renderer
    admin = context['view'].model_admin
    renderer = admin.field_renderers.get(attribute_name, False)
    if renderer is None:
        # Renderer has explicitly been overridden
        return value
    if not renderer:
        # Try to automatically pick best renderer
        if isinstance(value, bool):
            renderer = renderers.boolean_renderer
        elif isinstance(value, (date, time, datetime)):
            renderer = renderers.datetime_renderer
        elif isinstance(value, Number):
            renderer = renderers.number_renderer
        else:
            return value

    # Apply renderer and return value
    try:
        field = model_instance._meta.get_field(attribute_name)
    except FieldDoesNotExist:
        # There is no field with the specified name.
        # It must be a method instead.
        field = None
    return renderer(value, field)
def render ( context , model_instance , attribute_name ) : value = utils . get_attr ( model_instance , attribute_name ) # Get renderer admin = context [ 'view' ] . model_admin renderer = admin . field_renderers . get ( attribute_name , False ) if renderer is None : # Renderer has explicitly been overridden return value if not renderer : # Try to automatically pick best renderer if isinstance ( value , bool ) : renderer = renderers . boolean_renderer elif isinstance ( value , ( date , time , datetime ) ) : renderer = renderers . datetime_renderer elif isinstance ( value , Number ) : renderer = renderers . number_renderer else : return value # Apply renderer and return value try : field = model_instance . _meta . get_field ( attribute_name ) except FieldDoesNotExist : # There is no field with the specified name. # It must be a method instead. field = None return renderer ( value , field )