Customzing form fields in Admin in list_editable mode?

113 views
Skip to first unread message

Adam V.

unread,
Jun 18, 2009, 3:38:32 PM6/18/09
to Django users
When enabling bulk edit mode for an Admin list view, is it possible to
control the widgets used? For the normal editor you can of course
specify a custom form, but I'm not seeing a way to customize the
fields in the list view.

Basically, I want to specify that some text fields fields in the list
view render shorter than the default.

I can hack this in with some fairly gross after-the-fact client-side
JavaScript, but I'd rather be able to specify this behavior in my
admin.ModelAdmin if the ability exists.

Alex Gaynor

unread,
Jun 18, 2009, 3:40:28 PM6/18/09
to django...@googlegroups.com
Unfortunately there isn't a super good way to do this.  list_editalbe uses the formfield_for_dbfield option just like rendering the normal form does, however this obviously doesn't give you a ton of flexibility.  One thing you could do for now, until we fix this, is to check the URL of the request object that formfield_for_dbfield gets.

Alex

--
"I disapprove of what you say, but I will defend to the death your right to say it." --Voltaire
"The people's good is the highest law."--Cicero

Adam V.

unread,
Jun 18, 2009, 4:21:25 PM6/18/09
to Django users
Alex, thanks; that's what I was afraid of.
If no one else has, I'd be willing to take a stab at a patch for 1.2.

Alex Gaynor

unread,
Jun 18, 2009, 4:24:48 PM6/18/09
to django...@googlegroups.com
Yeah, my instinct for the patch would just be to create a new method, formfield_for_dbfield_for_list_editable (but with a better name ;) ) and have it by defualt just call formfield_for_dbfield and make the list_editable form creation use it.  Then by default people will see the same behavior, but there will be a specific method users can override to change it.  If you're interested in working on a patch I'd be more than happy to look it over, although as you've said, it won't make it in until 1.2.

Adam V.

unread,
Aug 6, 2009, 4:34:49 PM8/6/09
to Django users
Reply all
Reply to author
Forward
0 new messages