Dave
Dave

Reputation: 2949

How To Add a New Related Object in a Django Form

Similar to how it is done on the admin site for creating a new foreignkey object. I think ideally this would be a re-usable widget that can replace the Select or SelectMultiple widgets. I would like to do this with Jquery if possible, but am not sure how to do this exactly. My best guess is that the process would be

  1. Add a plus button beside the select/selectmultiple field
  2. Open a new form window with for the new form (a popup window)
  3. Validate then post the popup form data to the database and close this window
  4. Refresh the select/selectmultiple field on the original page, while selecting the just created object as a default.

Upvotes: 2

Views: 739

Answers (1)

Jonas Geiregat
Jonas Geiregat

Reputation: 5432

I also disliked the select/multiselect widget provided by django by default. It's really simple to have something more usable by just hooking up chosen into your form. It took me a couple of minutes to setup.

Take a look at it: http://harvesthq.github.com/chosen/

Upvotes: 1

Related Questions