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 Sarah Boyce)

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):  
    518518                return [(None, {"fields": ["url", "description"]})]
    519519
    520520        ma = MediaInline(Media, self.site)
    521         form = ma.get_formset(None).form
     521        form = ma.get_formset(None, edit_only=True).form
    522522        self.assertEqual(form._meta.fields, ["url", "description"])
    523523
    524524    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 MANAS MADESHIYA, 3 weeks ago

Cc: MANAS MADESHIYA added

comment:2 by Sarah Boyce, 3 weeks ago

Description: modified (diff)

comment:3 by Sarah Boyce, 3 weeks ago

Triage Stage: UnreviewedAccepted

I believe the main issue is that generic_inlineformset_factory is missing support for edit_only

comment:4 by MANAS MADESHIYA, 3 weeks ago

Owner: set to MANAS MADESHIYA
Status: newassigned

comment:5 by MANAS MADESHIYA, 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 MANAS MADESHIYA, 3 weeks ago

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
Version 0, edited 3 weeks ago by MANAS MADESHIYA (next)
Note: See TracTickets for help on using tickets.
Back to Top