Opened 15 years ago

Closed 15 years ago

Last modified 13 years ago

#12561 closed (fixed)

The ``can_delete`` argument of ``generic_inlineformset_factory`` isn't working

Reported by: Piaume Owned by: Natalia Bidart
Component: contrib.admin Version: 1.1
Severity: Keywords:
Cc: 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 Russell Keith-Magee)

When the can_delete argument of generic_inlineformset_factory is set to False, a "Delete" checkbox is always displayed on the admin site.

Here a short example:

class SomeModel(models.Model):
    content_type = models.ForeignKey(ContentType)
    object_id = models.PositiveIntegerField()
    content_object = generic.GenericForeignKey('content_type', 'object_id')

class SomeInlineFormset(generic.GenericStackedInline):
    model = SomeModel
    formset = generic.generic_inlineformset_factory(SomeModel, can_delete=False)
    extra = 0

class SomeModelAdmin(admin.ModelAdmin):
    inlines = [SomeInlineFormset]

http://img8.imageshack.us/img8/3323/screenshotbe.png

Attachments (3)

django_cantdelete_bug.png (38.8 KB ) - added by Piaume 15 years ago.
Bug result on the admin site (there is a "Delete" checkbox)
patch-12561.diff (2.8 KB ) - added by Natalia Bidart 15 years ago.
patch-12561-1.diff (5.2 KB ) - added by Natalia Bidart 15 years ago.
Improved the tests. Added default values on parent class for can_delete and can_order. Ran the whole test suite, all green.

Download all attachments as: .zip

Change History (11)

by Piaume, 15 years ago

Attachment: django_cantdelete_bug.png added

Bug result on the admin site (there is a "Delete" checkbox)

comment:1 by Piaume, 15 years ago

Summary: The ``cant_delete`` argument of ``generic_inlineformset_factory`` isn't workingThe ``can_delete`` argument of ``generic_inlineformset_factory`` isn't working

comment:2 by Russell Keith-Magee, 15 years ago

Component: Contrib appsdjango.contrib.admin
Description: modified (diff)
milestone: 1.2
Triage Stage: UnreviewedAccepted

It's probably not the reason for your original report, but the admin UI merge seems to have completely broken Generic inline formsets. I can't get them to work at all, with or without can_delete.

comment:3 by Natalia Bidart, 15 years ago

Owner: changed from nobody to Natalia Bidart
Status: newassigned

comment:4 by Natalia Bidart, 15 years ago

Submitting patch to have InlineModelAdmin.get_formset passing can_delete and can_order to inlineformset_factory.

Tests are also included, but not for can_order. I couldn't find a way to test it, since the admin GUI looks the same when can_order is either True or False. Ideas are welcomed!

by Natalia Bidart, 15 years ago

Attachment: patch-12561.diff added

by Natalia Bidart, 15 years ago

Attachment: patch-12561-1.diff added

Improved the tests. Added default values on parent class for can_delete and can_order. Ran the whole test suite, all green.

comment:5 by Natalia Bidart, 15 years ago

Has patch: set

comment:6 by jkocherhans, 15 years ago

Resolution: fixed
Status: assignedclosed

(In [12533]) Fixed #12561. InlineAdmin now respects can_delete=False. Thanks, nessita.

comment:7 by jkocherhans, 15 years ago

(In [12534]) [1.1.X] Fixed #12561. InlineAdmin now respects can_delete=False. Backport of [12533] from trunk.

comment:8 by Jacob, 13 years ago

milestone: 1.2

Milestone 1.2 deleted

Note: See TracTickets for help on using tickets.
Back to Top