foreign key select widget with "add" link

272 views
Skip to first unread message

j_syk

unread,
Dec 13, 2011, 12:53:17 PM12/13/11
to Django users
I have a Model with a ForeignKey and I'm using a vanilla ModelForm, so
it's using the standard ModelChoiceField widget. I'm looking to add a
'+' icon with a link to popup and new window to add a new foreign key
that is not already in the dropdown list. Yes, exactly like the admin
forms.

I've done it in the past by manually laying out the form in the
template (still with {{ field }} and {{ label }} values, just no
looping at all). I don't want to do this again.

I could append the link via javascript. But that's dirty.

I quickly took a stab at extending the ModelChoiceField, but I failed
and moved on.

Searching the web for a solution hasn't been good to me.


What's the easiest way to cleanly add this to a form and get it to
refresh the choices?

Ed

unread,
Jan 25, 2012, 9:56:31 PM1/25/12
to django...@googlegroups.com
Reply all
Reply to author
Forward
0 new messages