[Answered ]-Django pre-fill a form drop down box based on url request

1👍

Try setting book_id instead of book in the view as

 form = NoteForm(initial={'book_id':book_id})
👤Rohan

1👍

You’re trying to prepopulate the select box by passing the title, which is presumably what is displaying in the control. But you should pass the underlying value, which in the case of a ForeignKey is the id of the related object.

Leave a comment