[Django] #37026: edit_only not implemented for formsets in GenericInlineModelAdmin

15 views
Skip to first unread message

Django

unread,
Apr 8, 2026, 12:40:00 PMApr 8
to django-...@googlegroups.com
#37026: edit_only not implemented for formsets in GenericInlineModelAdmin
-------------------------------------+-------------------------------------
Reporter: Jacob Walls | Type: Bug
Status: new | Component:
| contrib.contenttypes
Version: 6.0 | Severity: Normal
Keywords: | Triage Stage:
| Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
`BaseModelFormSet` received an `edit_only` parameter in #26412 (and
#33822), but it looks like this was never implemented for
`GenericInlineModelAdmin`:

For the purposes of demonstrating the issue only, edit this test:
{{{#!diff
diff --git a/tests/generic_inline_admin/tests.py
b/tests/generic_inline_admin/tests.py
index b4833e54e7..9f1a997b00 100644
--- a/tests/generic_inline_admin/tests.py
+++ b/tests/generic_inline_admin/tests.py
@@ -518,7 +518,7 @@ class GenericInlineModelAdminTest(SimpleTestCase):
return [(None, {"fields": ["url", "description"]})]

ma = MediaInline(Media, self.site)
- form = ma.get_formset(None).form
+ form = ma.get_formset(None, edit_only=True).form
self.assertEqual(form._meta.fields, ["url", "description"])

def test_get_formsets_with_inlines_returns_tuples(self):
}}}

{{{#!py
File "/Users/jwalls/django/django/contrib/contenttypes/admin.py", line
150, in get_formset
return generic_inlineformset_factory(self.model, **defaults)
TypeError: generic_inlineformset_factory() got an unexpected keyword
argument 'edit_only'
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/37026>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Apr 8, 2026, 3:36:18 PMApr 8
to django-...@googlegroups.com
#37026: edit_only not implemented for formsets in GenericInlineModelAdmin
-------------------------------------+-------------------------------------
Reporter: Jacob Walls | Owner: (none)
Type: Bug | Status: new
Component: | Version: 6.0
contrib.contenttypes |
Severity: Normal | Resolution:
Keywords: | Triage Stage:
| Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by MANAS MADESHIYA):

* cc: MANAS MADESHIYA (added)

--
Ticket URL: <https://code.djangoproject.com/ticket/37026#comment:1>

Django

unread,
Apr 9, 2026, 6:17:43 AMApr 9
to django-...@googlegroups.com
#37026: edit_only not implemented for formsets in GenericInlineModelAdmin
-------------------------------------+-------------------------------------
Reporter: Jacob Walls | Owner: (none)
Type: Bug | Status: new
Component: | Version: 6.0
contrib.contenttypes |
Severity: Normal | Resolution:
Keywords: | Triage Stage:
| Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Description changed by Sarah Boyce:

Old description:

> `BaseModelFormSet` received an `edit_only` parameter in #26412 (and
> #33822), but it looks like this was never implemented for
> `GenericInlineModelAdmin`:
>
> For the purposes of demonstrating the issue only, edit this test:
> {{{#!diff
> diff --git a/tests/generic_inline_admin/tests.py
> b/tests/generic_inline_admin/tests.py
> index b4833e54e7..9f1a997b00 100644
> --- a/tests/generic_inline_admin/tests.py
> +++ b/tests/generic_inline_admin/tests.py
> @@ -518,7 +518,7 @@ class GenericInlineModelAdminTest(SimpleTestCase):
> return [(None, {"fields": ["url", "description"]})]
>
> ma = MediaInline(Media, self.site)
> - form = ma.get_formset(None).form
> + form = ma.get_formset(None, edit_only=True).form
> self.assertEqual(form._meta.fields, ["url", "description"])
>
> def test_get_formsets_with_inlines_returns_tuples(self):
> }}}
>
> {{{#!py
> File "/Users/jwalls/django/django/contrib/contenttypes/admin.py", line
> 150, in get_formset
> return generic_inlineformset_factory(self.model, **defaults)
> TypeError: generic_inlineformset_factory() got an unexpected keyword
> argument 'edit_only'
> }}}

New description:

`BaseModelFormSet` received an `edit_only` parameter in #26142 (and
#33822), but it looks like this was never implemented for
`GenericInlineModelAdmin`:

For the purposes of demonstrating the issue only, edit this test:
{{{#!diff
diff --git a/tests/generic_inline_admin/tests.py
b/tests/generic_inline_admin/tests.py
index b4833e54e7..9f1a997b00 100644
--- a/tests/generic_inline_admin/tests.py
+++ b/tests/generic_inline_admin/tests.py
@@ -518,7 +518,7 @@ class GenericInlineModelAdminTest(SimpleTestCase):
return [(None, {"fields": ["url", "description"]})]

ma = MediaInline(Media, self.site)
- form = ma.get_formset(None).form
+ form = ma.get_formset(None, edit_only=True).form
self.assertEqual(form._meta.fields, ["url", "description"])

def test_get_formsets_with_inlines_returns_tuples(self):
}}}

{{{#!py
File "/Users/jwalls/django/django/contrib/contenttypes/admin.py", line
150, in get_formset
return generic_inlineformset_factory(self.model, **defaults)
TypeError: generic_inlineformset_factory() got an unexpected keyword
argument 'edit_only'
}}}

--
--
Ticket URL: <https://code.djangoproject.com/ticket/37026#comment:2>

Django

unread,
Apr 9, 2026, 6:21:41 AMApr 9
to django-...@googlegroups.com
#37026: edit_only not implemented for formsets in GenericInlineModelAdmin
--------------------------------------+------------------------------------
Reporter: Jacob Walls | Owner: (none)
Type: Bug | Status: new
Component: contrib.contenttypes | Version: 6.0
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
--------------------------------------+------------------------------------
Changes (by Sarah Boyce):

* stage: Unreviewed => Accepted

Comment:

I believe the main issue is that `generic_inlineformset_factory` is
missing support for `edit_only`
--
Ticket URL: <https://code.djangoproject.com/ticket/37026#comment:3>

Django

unread,
Apr 9, 2026, 6:46:03 AMApr 9
to django-...@googlegroups.com
#37026: edit_only not implemented for formsets in GenericInlineModelAdmin
-------------------------------------+-------------------------------------
Reporter: Jacob Walls | Owner: MANAS
| MADESHIYA
Type: Bug | Status: assigned
Component: | Version: 6.0
contrib.contenttypes |
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by MANAS MADESHIYA):

* owner: (none) => MANAS MADESHIYA
* status: new => assigned

--
Ticket URL: <https://code.djangoproject.com/ticket/37026#comment:4>

Django

unread,
Apr 11, 2026, 2:27:15 AMApr 11
to django-...@googlegroups.com
#37026: edit_only not implemented for formsets in GenericInlineModelAdmin
-------------------------------------+-------------------------------------
Reporter: Jacob Walls | Owner: MANAS
| MADESHIYA
Type: Bug | Status: assigned
Component: | Version: 6.0
contrib.contenttypes |
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by MANAS MADESHIYA):

* has_patch: 0 => 1

Comment:

I have submitted a PR for this ticket:
[https://github.com/django/django/pull/21089 PR]

Changes:
- Added edit_only parameter to
generic_inlineformset_factory() in forms.py
- Added edit_only parameter to
GenericInlineModelAdmin.get_formset() in admin.py
- Added regression test
--
Ticket URL: <https://code.djangoproject.com/ticket/37026#comment:5>

Django

unread,
Apr 11, 2026, 7:38:46 AMApr 11
to django-...@googlegroups.com
#37026: edit_only not implemented for formsets in GenericInlineModelAdmin
-------------------------------------+-------------------------------------
Reporter: Jacob Walls | Owner: MANAS
| MADESHIYA
Type: Bug | Status: assigned
Component: | Version: 6.0
contrib.contenttypes |
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Comment (by MANAS MADESHIYA):

Has patch: set

I have submitted a PR for this ticket:

PR: https://github.com/django/django/pull/21090

Changes:

- Corrected the placement of `{% endblock %}` in `change_list.html`
- Ensured proper block structure by moving it outside the `changelist-
footer` div
- No functional changes; improves template correctness and readability
--
Ticket URL: <https://code.djangoproject.com/ticket/37026#comment:6>
Reply all
Reply to author
Forward
0 new messages