0

I'm using https://github.com/s-block/django-nested-inline with something like this:

class C(NestedStackedInline):
    model = C
    max_num = 1
    fk_name = 'B'

    class Media:
        css = {
             'all': ('/static/admin/css/forms-nested.css',)
        }


class B(NestedStackedInline):
    model = B

    class Media:
        css = {
             'all': ('/static/admin/css/forms-nested2.css',)
        }

    inlines = [C]


class A(NestedModelAdmin):
    model = A
    inlines = [B]

forms-nested.css is:

.inline-related h3 {
    margin: 0;
    color: #666;
    padding: 3px 5px;
    font-size: 11px;
    background: #e1e1e1 url(../img/nav-bg.gif) top left repeat-x;
    border-bottom: 1px solid #ddd;
}

and forms-nested2.css is:

.inline-related h3 {
    margin: 0;
    color: #484846;
    padding: 3px 5px;
    font-size: 11px;
    background: #D9DBCB;
    border-bottom: 1px solid #ddd;
}

Essentially I'm trying to have model-specific CSS for nested inlines. I want class C (the 2nd level inline) to have different h3 styling to class B (the 1st level inline). However class C's Media seems to override class B.

Is there any way to do this ?

Thanks

1 Answer 1

2

It's not like C's media is overriding B's media. They both appear in your admin page, but...

CSS of C's media is overriting CSS of B's media. Because this is how CSS works. Try to change forms-nested.css to have this:

.inline-related .inline-related h3 {

That will only style nested .inline-related h3.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.