Opened 3 weeks ago
Last modified 3 weeks ago
#37026 assigned Bug
edit_only not implemented for formsets in GenericInlineModelAdmin
| Reported by: | Jacob Walls | Owned by: | MANAS MADESHIYA |
|---|---|---|---|
| Component: | contrib.contenttypes | Version: | 6.0 |
| Severity: | Normal | Keywords: | |
| Cc: | MANAS MADESHIYA | Triage Stage: | Accepted |
| Has patch: | yes | Needs documentation: | no |
| Needs tests: | no | Patch needs improvement: | no |
| Easy pickings: | no | UI/UX: | no |
Description (last modified by )
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:
-
tests/generic_inline_admin/tests.py
diff --git a/tests/generic_inline_admin/tests.py b/tests/generic_inline_admin/tests.py index b4833e54e7..9f1a997b00 100644
a b class GenericInlineModelAdminTest(SimpleTestCase): 518 518 return [(None, {"fields": ["url", "description"]})] 519 519 520 520 ma = MediaInline(Media, self.site) 521 form = ma.get_formset(None ).form521 form = ma.get_formset(None, edit_only=True).form 522 522 self.assertEqual(form._meta.fields, ["url", "description"]) 523 523 524 524 def test_get_formsets_with_inlines_returns_tuples(self):
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'
Change History (6)
comment:1 by , 3 weeks ago
| Cc: | added |
|---|
comment:2 by , 3 weeks ago
| Description: | modified (diff) |
|---|
comment:3 by , 3 weeks ago
| Triage Stage: | Unreviewed → Accepted |
|---|
comment:4 by , 3 weeks ago
| Owner: | set to |
|---|---|
| Status: | new → assigned |
comment:5 by , 3 weeks ago
| Has patch: | set |
|---|
I have submitted a PR for this ticket:
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
comment:6 by , 3 weeks ago
I have submitted a PR for this ticket:
PR: https://github.com/django/django/pull/21090
Changes:
- Corrected the placement of
{% endblock %}inchange_list.html - Ensured proper block structure by moving it outside the
changelist-footerdiv - No functional changes; improves template correctness and readability
Note:
See TracTickets
for help on using tickets.
I believe the main issue is that
generic_inlineformset_factoryis missing support foredit_only