[Answer]-Django: forms foreign key auto corellation

1๐Ÿ‘

โœ…

If you want an initial value you can try this:

form = MyForm(initial={'max_number': '3'})

You would need to replace the 3 by your patient id, which you need to figure how to pass it to the view. It is easy if you are trying something like:

my_demographic_object = my_demographic_form.save() #Object created from your old form
form = MyForm(initial={'patient': my_demographic_object.id})

If that is not what you are trying to do please explain a little more in detail

๐Ÿ‘คcdvv7788

Leave a comment