﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
37399	Include module_name in all model admin views with breadcrumbs	Marijke Luttekes		"Provide a context variable `module_name` to all model admin views that do not yet have this value, for consistency.

This value is a capitalized version of a model's pluralized verbose name, typically used in the third breadcrumb link that points to a changelist view.

== Reasoning

As originally mentioned on the forum: [https://forum.djangoproject.com/t/some-potential-bugs-found-when-making-custom-admin-pages/46049 Some potential bugs found when making custom admin pages].

Some model admin pages like the history view (template: [https://github.com/django/django/blob/main/django/contrib/admin/templates/admin/object_history.html object_history.html]) provide a context variable `module_name`, which is used in the breadcrumbs block of the template.

Other templates, e.g., the add/edit view (template: [https://github.com/django/django/blob/main/django/contrib/admin/templates/admin/change_form.html change_form.html]) do not provide this value as context data. Instead, they modify the object's verbose plural name in place within the breadcrumbs block.

Adding this value to all the relevant admin templates would make the code more consistent.

== Python code

This is is how we build the module name in Python from a `ModelAdmin` instance:

{{{
opts = self.model._meta
module_name = str(capfirst(opts.verbose_name_plural))
}}}

Templates like `change_form.html` use this code instead:

{{{
{{ opts.verbose_name_plural|capfirst }}
}}}"	Cleanup/optimization	new	contrib.admin	dev	Normal				Unreviewed	0	0	0	0	1	0
