1👍
✅
Try setting book_id
instead of book
in the view as
form = NoteForm(initial={'book_id':book_id})
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.
- [Answered ]-Django unable to split views
- [Answered ]-Combining two columns into one using django_tables2
- [Answered ]-TypeError: "ModelBase is not iterable"
- [Answered ]-Getting string from CharField
Source:stackexchange.com