Layout of widgets in admin form

37 views
Skip to first unread message

Vikas Rawal

unread,
Aug 24, 2012, 6:15:45 AM8/24/12
to django...@googlegroups.com
I am new to django. I am trying to develop an application where I need to work with the admin interface. The usual admin interface (for example in the poll app of django tutorial) lays out the widgets vertically. How do I change that? If I want to put two or three widgets side by side, customise the width of each widget, etc, what should I do? 

Vikas

Melvyn Sopacua

unread,
Aug 24, 2012, 6:28:22 AM8/24/12
to django...@googlegroups.com
On 24-8-2012 12:15, Vikas Rawal wrote:
> I am new to django. I am trying to develop an application where I need to
> work with the admin interface. The usual admin interface (for example in
> the poll app of django tutorial) lays out the widgets vertically. How do I
> change that?

<https://docs.djangoproject.com/en/1.4/intro/tutorial02/#customize-the-admin-form>

See the fieldsets part.

> If I want to put two or three widgets side by side, customise
> the width of each widget, etc, what should I do?

Same thing, and set the HTML classes to something that gives them your
width.
--
Melvyn Sopacua

Vikas Rawal

unread,
Aug 24, 2012, 8:05:33 AM8/24/12
to django...@googlegroups.com
The examples shown for fieldsets seem to divide the fields into
different groups. But in all the examples, fields still appear, within
each group, one after another, vertically.

Vikas

Melvyn Sopacua

unread,
Aug 24, 2012, 9:02:03 AM8/24/12
to django...@googlegroups.com
Ah, right it's not properly covered in the tutorial. Within the fields
member of the dictionary you can group them. Details are here:
<https://docs.djangoproject.com/en/1.4/ref/contrib/admin/#django.contrib.admin.ModelAdmin.fields>

Short version:
fieldsets = (
(None, {
'fields': ( (question, pub_date), ),
}
),
#...
)
--
Melvyn Sopacua

Vikas Rawal

unread,
Aug 24, 2012, 1:03:02 PM8/24/12
to django...@googlegroups.com
Thanks. Worked perfectly.


Vikas
Reply all
Reply to author
Forward
0 new messages