mirror of
https://github.com/django/django.git
synced 2024-12-22 17:16:24 +00:00
Fixed #23451 -- Fixed typo in inlineformset_factory() error message.
This commit is contained in:
parent
b161c01c48
commit
f7eee04ebe
@ -949,7 +949,7 @@ def _get_foreign_key(parent_model, model, fk_name=None, can_fail=False):
|
||||
(fk.rel.to != parent_model and
|
||||
fk.rel.to not in parent_model._meta.get_parent_list()):
|
||||
raise ValueError(
|
||||
"fk_name '%s' is not a ForeignKey to '%s.%'."
|
||||
"fk_name '%s' is not a ForeignKey to '%s.%s'."
|
||||
% (fk_name, parent_model._meta.app_label, parent_model._meta.object_name))
|
||||
elif len(fks_to_parent) == 0:
|
||||
raise ValueError(
|
||||
|
@ -23,3 +23,6 @@ Bugfixes
|
||||
|
||||
* The ``@deconstructible`` decorator now fails with a ``ValueError`` if the
|
||||
decorated object cannot automatically be imported (:ticket:`23418`).
|
||||
|
||||
* Fixed a typo in an ``inlineformset_factory()`` error message that caused a
|
||||
crash (:ticket:`23451`).
|
||||
|
@ -815,6 +815,12 @@ class ModelFormsetTest(TestCase):
|
||||
formset = AuthorBooksFormSet(data, instance=author, queryset=custom_qs)
|
||||
self.assertTrue(formset.is_valid())
|
||||
|
||||
def test_inline_formsets_with_wrong_fk_name(self):
|
||||
""" Regression for #23451 """
|
||||
message = "fk_name 'title' is not a ForeignKey to 'model_formsets.Author'."
|
||||
with self.assertRaisesMessage(ValueError, message):
|
||||
inlineformset_factory(Author, Book, fields="__all__", fk_name='title')
|
||||
|
||||
def test_custom_pk(self):
|
||||
# We need to ensure that it is displayed
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user