django modelformset_factory sustains the previously submitted data even after successfully created the objects

十年热恋 提交于 2019-11-30 10:31:19

Answer of the first question i.e modelformset_factory always sustains the old data is lies here. https://docs.djangoproject.com/en/1.8/topics/forms/modelforms/#changing-the-queryset as it is given in the docs chenge the queryset by overriding the constructor of the basemodelformset

from django.forms.models import BaseModelFormSet

from myapp.models import Author

class CalendarFormset(BaseModelFormSet):
    def __init__(self, *args, **kwargs):
        super(CalendarFormset, self).__init__(*args, **kwargs)
        self.queryset = Calendar.objects.none()

It will solve the problem 1.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!