[Fixed]-Django FormSetView with custom validation

1👍

The problem is your WorkerStatusFormSet.__init__ method. Looking at the code for BaseModelFormSet, the __init__ method already takes a queryset parameter. Since you aren’t doing anything in your __init__ method except calling super(), the easiest fix is to remove it.

It’s not a good idea to change the signature of the __init__ method as you have done for two reasons

def __init__(self, queryset, *args, **kwargs):
    super(WorkerStatusFormSet, self).__init__(*args, **kwargs)
  1. You have changed the order of the arguments. If you look at the code for BaseModelFormset, the first argument is data. That means that data might be incorrectly assigned to queryset if somebody calls WorkerStatusFormSet(data, …)
  2. You do not do anything with queryset or pass it to super(), so it is lost.

Leave a comment