sshwsfc / xadmin

Drop-in replacement of Django admin comes with lots of goodies, fully extensible with plugin support, pretty UI based on Twitter Bootstrap.
http://www.xadmin.io
BSD 3-Clause "New" or "Revised" License
4.76k stars 1.41k forks source link

Inline Formset appear out of the Tab #368

Open lorenzo33 opened 7 years ago

lorenzo33 commented 7 years ago

Here's my configuration :

I would like to display an inline formset in tab like the xadmin-demo-master.

 inlines = (CityInline,)
    model_icon = 'flag'

    form_layout = (
        TabHolder(
            Tab('General',
                Fieldset(None,
                    'name', 'continent', 'code', 'independence_day',
                    css_class='unsort no_title'
                ),
                Fieldset('Statistics',
                    'area', 'population',
                    description="EnclosedInput widget examples"
                ),
                Fieldset('Autosized textarea',
                    'description',
                    description='AutosizedTextarea widget example - adapts height '
                                'based on user input'
                ),
            ),
            Tab('Cities',
                Fieldset('Architecture',
                    'architecture',
                    description="Tabs can contain any fieldsets and inlines"
                ),
                Inline(City),
            ),
        ),
    )

Unfortunately, the Inline formset "City" appear out of the tab 'Cities' and appear under each tab.

image

frmdstryr commented 7 years ago

This is a duplicate of #363 , to fix it https://github.com/sshwsfc/xadmin/blob/master/xadmin/plugins/inline.py#L432 change the list to an OrderedDict

lorenzo33 commented 7 years ago

Could you give me an example ? Where do you change the list to OrderedDict ? In my adminx.py ?

Thanks for your help !

rpalacios commented 7 years ago

I did a fork and made some fixes, including this issue. This is the change I made https://github.com/rpalacios/xadmin/compare/master@%7B1480329670%7D...master

frmdstryr commented 7 years ago

In inline.py, line 432. Make it fs = OrderedDict([...]). Then add from collections import OrderedDict at the top.

Using a list retains the order but not placement. Using a dict retains placement but not field order, using an OrderedDict does both.

lorenzo33 commented 7 years ago

Thanks for help. I use the frmdstryr's solution and it's work !

2016-12-28 16:40 GMT+01:00 frmdstryr notifications@github.com:

In inline.py, line 432. Make it fs = OrderedDict([...]). Then add from collections import OrderedDict at the top.

Using a list retains the order but not placement. Using a dict retains placement but not field order, using an OrderedDict does both.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/sshwsfc/xadmin/issues/368#issuecomment-269494154, or mute the thread https://github.com/notifications/unsubscribe-auth/AXpcHRE4_o97BOJCqYyFx2EAWr0Cw2pUks5rMoLmgaJpZM4LWaTI .

-- Cdt

DELAPLACE Laurent