2👍
✅
You mentioned that there are ~500,000 rows in your database for the Attendance
models. In Django, when the queryset
parameter is not specified for a ModelFormSet
, it includes all objects in that model. Django is probably fetching all 500,000 rows of data.
You need to figure out the queryset for your ModelFormSet
. E.g.
def post(self, request, *args, **kwargs):
queryset = Attendance.objects.none()
formset = AcknowledgeFormset(queryset=queryset, data=request.POST)
# continue with your regular code execution
The documentation contains a section for the queryset of a ModelFormSet
: https://docs.djangoproject.com/en/1.9/topics/forms/modelforms/#django.forms.models.BaseModelFormSet
Source:stackexchange.com