StackedInline form in one row


In a Parent Model I am using StackedInline form to show Child fields. I wish to know if there is a way to have StackedInline form fields in one row.

I tried to use TabularInline but it makes use of table instead of div, so it loses responsiveness when I import bootstrap in admin area.

Both StackedInline and TabularInline are classes that inherit from InlineModelAdmin, replacing the template attribute. You could create your own Inline class specifying a different template to do the layout however your wish.

Thank you for your suggestion!
finally I cloned tabular.html file in my admin template since it seemed more simple and called it in this way:

from django.contrib.admin.options import InlineModelAdmin

class TabularInlineResponsive(InlineModelAdmin):
	template = 'admin/edit_inline/tabular_responsive.html'

and it seems to work.
Here is my tabular_responsive.html file.
Do you think we can do better?

1 Like

Cool! I’ll admit to being a little surprised to see that you’re using a table rather than div given your original question mentions losing responsiveness, but if it works for you, great!
(I am most definitely not the person to ask for opinions regarding templates or any other front-end issues. I may know the mechanics and components, but I don’t have an eye for design or style.)

You are definitely right, but using bootstrap table seemed easier for me!