django-nested-inline icon indicating copy to clipboard operation
django-nested-inline copied to clipboard

`ModelAdmin.save_as = True` is broken

Open smcoll opened this issue 11 years ago • 4 comments
trafficstars

The ModelAdmin class has a property called 'save_as', which if set to True, will include a "Save as new" button on the admin change view. When the property is added to the test project admin configuration...

class TopLevelAdmin(NestedModelAdmin):
    model = TopLevel
    inlines = [LevelOneInline]
    save_as = True

Selecting "save as new" causes an IndexError.

The default behavior for vanilla inlines attached to ModelAdmin classes with "save_as=True" seems to be that all the inlines are re-saved as new instances having all the same properties except the FK is updated to the new value.

smcoll avatar Sep 30 '14 15:09 smcoll

For me it's an attribute error in nested_inline.admin.NestedModelAdmin.change_view. Looks like a typo: opts.module_name instead of opts.model_name.

ktosiek avatar Sep 16 '15 14:09 ktosiek

I am noticing the save as = true is unable to populated the nested inline class. any attribute which i need to set to get it working?

sushovan23 avatar Oct 05 '15 16:10 sushovan23

I have the same issue: 'Options' object has no attribute 'module_name'

other than hacking the installed code (if it's just a case of a typo as referenced above) is there a work-around? (I inherited the project that's using dj-nested-inline, and would prefer NOT having to do a lot of coding to just allow a model admin to have save_as=True (budget, etc. issues).)

ursomniac avatar May 09 '17 16:05 ursomniac

It looks like opts.module_name was renamed opts.model_name.

https://docs.djangoproject.com/en/1.8/internals/deprecation/

If you want to make a PR I will merge and update pypi. If not I will try to do it in the next few days.

s-block avatar May 10 '17 09:05 s-block