I am building an ad manager software, and I want to use django's ModelForm system to load an entire queryset of Ad objects so that users can alter fields in an already running/existing ad.
I want to do this preferably in an alternative way to the modelformset_factory method.
For example, if a user has a single Ad model you could simply call that instance and load the instance into a modelForm instance called AdForm so that they can edit the ad's properties:
ad_instance = Ad.objects.get(pk=1)
ad_form = AdForm(instance=ad_instance)
So what about if the user has 20 active ads running? How can a queryset of 20 ad instances be loaded into their respective AdForms?
Thanks
You can Change the queryset
AdFormSet = modelformset_factory(Ad, fields=('name', 'title'))
formset = AdFormSet(queryset=request.user.ad_set.all())