mirror of
https://github.com/django/django.git
synced 2024-12-22 17:16:24 +00:00
Fixed #31086 -- Improved error message for admin model inlines with more than one foreign key to the same parent.
This commit is contained in:
parent
ff00a05347
commit
f4647179cc
@ -1032,7 +1032,8 @@ def _get_foreign_key(parent_model, model, fk_name=None, can_fail=False):
|
|||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
raise ValueError(
|
raise ValueError(
|
||||||
"'%s' has more than one ForeignKey to '%s'." % (
|
"'%s' has more than one ForeignKey to '%s'. You must specify "
|
||||||
|
"a 'fk_name' attribute." % (
|
||||||
model._meta.label,
|
model._meta.label,
|
||||||
parent_model._meta.label,
|
parent_model._meta.label,
|
||||||
)
|
)
|
||||||
|
@ -645,7 +645,8 @@ inline on a :class:`~django.contrib.admin.ModelAdmin`.
|
|||||||
* **admin.E201**: Cannot exclude the field ``<field name>``, because it is the
|
* **admin.E201**: Cannot exclude the field ``<field name>``, because it is the
|
||||||
foreign key to the parent model ``<app_label>.<model>``.
|
foreign key to the parent model ``<app_label>.<model>``.
|
||||||
* **admin.E202**: ``<model>`` has no ``ForeignKey`` to ``<parent model>``./
|
* **admin.E202**: ``<model>`` has no ``ForeignKey`` to ``<parent model>``./
|
||||||
``<model>`` has more than one ``ForeignKey`` to ``<parent model>``.
|
``<model>`` has more than one ``ForeignKey`` to ``<parent model>``. You must
|
||||||
|
specify a ``fk_name`` attribute.
|
||||||
* **admin.E203**: The value of ``extra`` must be an integer.
|
* **admin.E203**: The value of ``extra`` must be an integer.
|
||||||
* **admin.E204**: The value of ``max_num`` must be an integer.
|
* **admin.E204**: The value of ``max_num`` must be an integer.
|
||||||
* **admin.E205**: The value of ``min_num`` must be an integer.
|
* **admin.E205**: The value of ``min_num`` must be an integer.
|
||||||
|
@ -636,7 +636,9 @@ class SystemChecksTestCase(SimpleTestCase):
|
|||||||
errors = MyAdmin(Album, AdminSite()).check()
|
errors = MyAdmin(Album, AdminSite()).check()
|
||||||
expected = [
|
expected = [
|
||||||
checks.Error(
|
checks.Error(
|
||||||
"'admin_checks.TwoAlbumFKAndAnE' has more than one ForeignKey to 'admin_checks.Album'.",
|
"'admin_checks.TwoAlbumFKAndAnE' has more than one ForeignKey "
|
||||||
|
"to 'admin_checks.Album'. You must specify a 'fk_name' "
|
||||||
|
"attribute.",
|
||||||
obj=TwoAlbumFKAndAnEInline,
|
obj=TwoAlbumFKAndAnEInline,
|
||||||
id='admin.E202',
|
id='admin.E202',
|
||||||
)
|
)
|
||||||
|
Loading…
Reference in New Issue
Block a user