newforms admin m2m field

0 views
Skip to first unread message

Rob van der Linde

unread,
May 8, 2008, 9:14:06 PM5/8/08
to Django developers
Hi, I have some code that I wish to move over to the newforms admin
branch. So far I have been able to convert my models no problem to the
new syntax.

One of my models has a many to many field to the Sites model that comes
with Django. The field is a required field, and prior to moving to the
newforms admin branch, if I added a new entry to my model inside admin,
it would automatically highlight the first entry in the sites multi
select box and it would save straight away without needing the extra
user interaction.

Since moving to newforms admin, when I add a new entry to my model, by
default, nothing is highlighted in the sites multi select box.

It might not sound like much, but I have this sites m2m field located in
a less used collapsed area in admin, and would prefer it to be set
automatically like the old admin did without needing the extra user
intraction.

Is this possible, or does this need to be done using some sort of
javascript hack?

signature.asc

Honza Král

unread,
May 8, 2008, 9:16:14 PM5/8/08
to django-d...@googlegroups.com
you can define a fomrfield_for_dbfield method on the ModelAdmin and
override the default formfield, supply it with an initial value, that
should work.

--
Honza Král
E-Mail: Honza...@gmail.com
ICQ#: 107471613
Phone: +420 606 678585

Rob van der Linde

unread,
May 8, 2008, 9:41:32 PM5/8/08
to django-d...@googlegroups.com
signature.asc
Reply all
Reply to author
Forward
0 new messages