Opened 15 years ago

Closed 15 years ago

Last modified 15 years ago

#13115 closed (worksforme)

Display multiple widgets within a particular admin fieldset horizontally

Reported by: delfick755@… Owned by: nobody
Component: contrib.admin Version: 1.1
Severity: Keywords:
Cc: Gabriel Hurley Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

Hello,

I wonder if it would be possible to be able to specify to display some controls in an admin add page to be next to each other instead of on top of each other.

I'm not sure I've explained that very well, so I'll add too screenshots. First one is what i have currently for a particular project of mine. The other is a gimped version of what I want.

Thankyou

Attachments (2)

current.png (57.9 KB ) - added by anonymous 15 years ago.
desired.png (23.7 KB ) - added by anonymous 15 years ago.

Download all attachments as: .zip

Change History (9)

by anonymous, 15 years ago

Attachment: current.png added

by anonymous, 15 years ago

Attachment: desired.png added

comment:1 by Gabriel Hurley, 15 years ago

Just FYI, this is not the easiest thing to do. It's not that hard to make a single widget that has multiple fields on one row, but making multiple widgets coexist on one row requires changing how the admin templates render the rows.

Right now it just uses a for loop to render each field in its own div, and render the appropriate label and widget inside that div.

Making it allow horizontally-arranged bits would involve changes to the admin templates, admin stylesheet, and to the forms component itself (to add some sort of attribute determining which fields should be floated next to each other).

You could implement it entirely in admin, but if you're going to do all that work, why not implement it for all forms instead of just admin forms...

comment:2 by Ramiro Morales, 15 years ago

Resolution: worksforme
Status: newclosed

You already can do that. Please read carefully the documentation of the fieldsets ModelAdmin option documentation: http://docs.djangoproject.com/en/1.1/ref/contrib/admin/#django.contrib.admin.ModelAdmin.fieldsets

Post any further question to the django.users mailing list or the #django IRC channel.

comment:3 by Gabriel Hurley, 15 years ago

Cc: Gabriel Hurley added
Summary: Display controls in particular fieldset in django admin add page horizontallyDisplay multiple widgets within a particular admin fieldset horizontally

I think Ramiro may have slightly misunderstood what the OP was asking for... I'll bring it up on django-developers since I think this is still a worthwhile feature.

comment:4 by foxulet, 15 years ago

I have just reached the same issue as described here. And as in the graphic example above, I use grappelli too.
Each field is in it's own div, and if we use field sets then all divs are grouped as we choose inside a single div.

As it would be very difficult to change the code I have just opted to rearrange the fields inside that fieldset using CSS positioning.
But a general layout system would be interesting.

comment:5 by foxulet, 15 years ago

And once again the old RTFM applies, and with such a good documentation there's no reason why not to read the Django manual.

To display multiple fields on the same line, wrap those fields in their own tuple. In this example, the first_name and last_name fields will display on the same line:

{
'fields': (('first_name', 'last_name'), 'address', 'city', 'state'),
}

comment:6 by Gabriel Hurley, 15 years ago

Thanks foxulet. I can't believe how many times I've read those docs without seeing that tidbit tucked in there! My bad!

comment:7 by delfick, 15 years ago

@foxulet : oh, I do read the documentation, it is fantastic documentation. I have the same problem as gabrielhurley, the number of times I have read the documentation and missed that.

However, Thankyou so much for pointing that out, it is perfect.

Sorry I missed it.

Note: See TracTickets for help on using tickets.
Back to Top