Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multiple nested inline models save as new not working #157

Open
dbkv9 opened this issue Sep 28, 2023 · 0 comments
Open

Multiple nested inline models save as new not working #157

dbkv9 opened this issue Sep 28, 2023 · 0 comments

Comments

@dbkv9
Copy link

dbkv9 commented Sep 28, 2023

Hi! I have next code (admin.py):

class ExampleForm(ModelForm):
    class Meta:
        model = Example
        exclude = []

    def is_multipart(self, *args, **kwargs):
        return True


class ExampleTabItemGalleryInline(GalleryFieldOverride, NestedTabularInline):
    model = ExampleTabItemGallery
    fk_name = 'tab_item'


class ExampleTabItemAdmin(GalleryFieldOverride, NestedStackedInline):
    model = ExampleTabItem
    fk_name = 'tab'
    inlines = [ExampleTabItemGalleryInline, ]


class ExampleTabAdmin(NestedStackedInline):
    model = ExampleTab
    inlines = [ExampleTabItemAdmin, ]
    fk_name = 'example'


class ExampleAdmin(NestedModelAdmin):
    inlines = [ExampleTabAdmin, ]
    form = ExampleForm
    
    save_as = True

When i save object with _saveasnew i have next trouble: saves only first inline model, that is -- ExampleTab and Example, but models nested into ExampleTab (ExampleTabItem, ExampleTabItemGallery) not saved... their fields is empty.

@dbkv9 dbkv9 changed the title Multiple inline models save as new not working Multiple nested inline models save as new not working Sep 28, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant