mirror of
https://github.com/django/django.git
synced 2024-12-01 15:42:04 +01:00
Fixed #24624 -- Replaced obsoleted rel.opts in admindocs view
Thanks Scott Sanders for the report, and Markus Holtermann and Tim Graham for the reviews. Refs #24381.
This commit is contained in:
parent
a7bc00e17b
commit
4e7ed8d0d3
@ -266,8 +266,8 @@ class ModelDetailView(BaseAdminDocsView):
|
|||||||
# Gather related objects
|
# Gather related objects
|
||||||
for rel in opts.related_objects:
|
for rel in opts.related_objects:
|
||||||
verbose = _("related `%(app_label)s.%(object_name)s` objects") % {
|
verbose = _("related `%(app_label)s.%(object_name)s` objects") % {
|
||||||
'app_label': rel.opts.app_label,
|
'app_label': rel.related_model._meta.app_label,
|
||||||
'object_name': rel.opts.object_name,
|
'object_name': rel.related_model._meta.object_name,
|
||||||
}
|
}
|
||||||
accessor = rel.get_accessor_name()
|
accessor = rel.get_accessor_name()
|
||||||
fields.append({
|
fields.append({
|
||||||
|
@ -31,3 +31,7 @@ Bugfixes
|
|||||||
|
|
||||||
* Fixed a crash with ``QuerySet.update()`` on foreign keys to one-to-one fields
|
* Fixed a crash with ``QuerySet.update()`` on foreign keys to one-to-one fields
|
||||||
(:ticket:`24578`).
|
(:ticket:`24578`).
|
||||||
|
|
||||||
|
* Fixed a regression in the model detail view of
|
||||||
|
:mod:`~django.contrib.admindocs` when a model has a reverse foreign key
|
||||||
|
relation (:ticket:`24624`).
|
||||||
|
@ -290,6 +290,20 @@ class TestModelDetailView(TestDataMixin, AdminDocsTestCase):
|
|||||||
"all related %s objects" % (link % ("admin_docs.group", "admin_docs.Group"))
|
"all related %s objects" % (link % ("admin_docs.group", "admin_docs.Group"))
|
||||||
)
|
)
|
||||||
|
|
||||||
|
def test_model_with_many_to_one(self):
|
||||||
|
link = '<a class="reference external" href="/admindocs/models/%s/">%s</a>'
|
||||||
|
response = self.client.get(
|
||||||
|
reverse('django-admindocs-models-detail', args=['admin_docs', 'company'])
|
||||||
|
)
|
||||||
|
self.assertContains(
|
||||||
|
response,
|
||||||
|
"number of related %s objects" % (link % ("admin_docs.person", "admin_docs.Person"))
|
||||||
|
)
|
||||||
|
self.assertContains(
|
||||||
|
response,
|
||||||
|
"all related %s objects" % (link % ("admin_docs.person", "admin_docs.Person"))
|
||||||
|
)
|
||||||
|
|
||||||
def test_model_with_no_backward_relations_render_only_relevant_fields(self):
|
def test_model_with_no_backward_relations_render_only_relevant_fields(self):
|
||||||
"""
|
"""
|
||||||
A model with ``related_name`` of `+` should not show backward relationship
|
A model with ``related_name`` of `+` should not show backward relationship
|
||||||
|
Loading…
Reference in New Issue
Block a user