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

An inline within an inline #581

Open
lyaguxafrog opened this issue Feb 24, 2024 · 6 comments
Open

An inline within an inline #581

lyaguxafrog opened this issue Feb 24, 2024 · 6 comments

Comments

@lyaguxafrog
Copy link

lyaguxafrog commented Feb 24, 2024

I wanted to make an inline inside the inline, but I didn't understand how to do it, I tried something like this:

class ContentBlockAdmin(StackedPolymorphicInline):

    class Left_text(StackedPolymorphicInline.Child):
        model = ScreenTextBlock_left


    class Left_image(StackedPolymorphicInline.Child):
        model = ScreenImageBlock_left

    model = ContentBlock
    child_inlines = (
        Left_text,
        Left_image
    )

class ScreenInline(PolymorphicInlineSupportMixin, admin.StackedInline):
    model = Screens
    extra = 0
    inlines = (ContentBlockAdmin, )


class PracticumAdmin(admin.ModelAdmin):
    inlines = (ScreenInline, )


admin.site.register(Practicum, PracticumAdmin)
@j-antunes
Copy link
Contributor

What is the error that you are seeing?

@piranna
Copy link

piranna commented Feb 29, 2024

I'm in a similar situation, but I get no error at all. Before I had a single childs level and I think it worked, but once I splitted the parent model so now there are two levels, I don't have inlines at all.

@j-antunes
Copy link
Contributor

@piranna - Can you provide a reproducible example?

@piranna
Copy link

piranna commented Feb 29, 2024

@piranna - Can you provide a reproducible example?

It's private code, but will try to get something. If you want to try, I have parentA class with some fields, childB with no fields, and grandChildC with some fields. If I set grandChildC as direct child of parentA, I think to remember they grandChildC fields were shown, but if I put the intermediate childB class with no fields, no fields of grandChildC are shown.

@j-antunes
Copy link
Contributor

@piranna - Are you able to extract part of the code and change the variables names, etc... You can call the class A B C, so we can have something to test against.

@lyaguxafrog
Copy link
Author

What is the error that you are seeing?

there are no errors, just nothing is displayed in the admin panel.

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

3 participants