What is the difference between initial and instance in django formset?
When to use which?
What should I use to show the prepopulated data in an invalid form in the following case:
formset= FormSet(initial=[{'a':list.b} for list in listslist])
if request.method =='post':
formset = FormSet(request.post, ---instance/initial? ---)
initial
is to set defaults for new forms.
instances
is to set models instances you use as initial models, which will be populated with entered data. You can use this attribute to edit your model instances.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With