I'm creating a formset, but it seems to populate it with all of the existing data in the table for that object. I can't figure out how to start with a blank formset; the only way seems to be to delete all of the data from the table, but clearly this isn't an option.
I will post code if necessary (but there's lots of it, so knowing what is relevant is tricky).
Django formset allows you to edit a collection of the same forms on the same page. It basically allows you to bulk edit a collection of objects at the same time.
give a parameter queryset=Model.objects.none() when making the object.
Following Arihant's answer, I did something like this, which works:
class TagCreateFormSet(BaseModelFormSet):
def __init__(self, data=None, files=None, auto_id='id_%s', prefix=None,
queryset=None, **kwargs):
queryset = Tag.objects.none()
super(TagCreateFormSet, self).__init__(data, files,
auto_id, prefix, queryset, **kwargs)
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