Opened 9 years ago

Last modified 9 years ago

#26579 closed New feature

Control deep copy depth for 'save as new' in admin with inlines — at Initial Version

Reported by: heka Owned by: nobody
Component: contrib.admin Version: 1.9
Severity: Normal Keywords: saveasnew
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

Proposal:

Add 'save_as' class attribute to all InlineModelAdmin. By default it should probably True.

ModelAdmin could then be modified as followed:

    def get_formsets_with_inlines(self, request, obj=None):
        """
        Yields formsets and the corresponding inlines.
        """
        if '_saveasnew' in request.POST:
            inline_instances = [inline_instance for inline_instance in self.get_inline_instances(request, obj)
                                if getattr(inline_instance, 'save_as', True)]
        else:
            inline_instances = self.get_inline_instances(request, obj)

        for inline in inline_instances:
            yield inline.get_formset(request, obj), inline

This change will allow you to control the save_as behavior per inline

Change History (0)

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