django_baseline/templatetags/helpers.py
def model_verbose(obj, capitalize=True):
    """
    Return the verbose name of a model.
    The obj argument can be either a Model instance, or a ModelForm instance.
    This allows to retrieve the verbose name of the model of a ModelForm
    easily, without adding extra context vars.
    """

    if isinstance(obj, ModelForm):
        name = obj._meta.model._meta.verbose_name
    elif isinstance(obj, Model):
        name = obj._meta.verbose_name
    else:
        raise Exception('Unhandled type: ' + type(obj))

    return name.capitalize() if capitalize else name
def model_verbose(obj, capitalize=True):
    """
    Return the verbose name of a model.
    The obj argument can be either a Model instance, or a ModelForm instance.
    This allows to retrieve the verbose name of the model of a ModelForm
    easily, without adding extra context vars.
    """

    if isinstance(obj, ModelForm):
        name = obj._meta.model._meta.verbose_name
    elif isinstance(obj, Model):
        name = obj._meta.verbose_name
    else:
        raise Exception('Unhandled type: ' + type(obj))

    return name.capitalize() if capitalize else name
Return the verbose name of a model.
    The obj argument can be either a Model instance, or a ModelForm instance.
    This allows to retrieve the verbose name of the model of a ModelForm
    easily, without adding extra context vars.