Opened 10 years ago
Closed 10 years ago
#26579 closed New feature (needsinfo)
Control deep copy depth for 'save as new' in admin with inlines
| 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 (last modified by )
Proposal:
Add 'save_as' class attribute to 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 (3)
comment:1 by , 10 years ago
| Description: | modified (diff) |
|---|
comment:2 by , 10 years ago
comment:3 by , 10 years ago
| Resolution: | → needsinfo |
|---|---|
| Status: | new → closed |
Note:
See TracTickets
for help on using tickets.
I'm not immediately convinced -- could you sketch out the idea at a high level a bit more? How will the user understand the expected behavior?