@register.filter<EOL>def model_verbose(obj, capitalize=True):
if isinstance(obj, ModelForm):<EOL><INDENT>name = obj._meta.model._meta.verbose_name<EOL><DEDENT>elif isinstance(obj, Model):<EOL><INDENT>name = obj._meta.verbose_name<EOL><DEDENT>else:<EOL><INDENT>raise Exception('<STR_LIT>' + type(obj))<EOL><DEDENT>return name.capitalize() if capitalize else name<EOL>
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.