阅读背景:

将initial传递给Django的ModelFormSet

来源:互联网 

I have a model formset that I need to pass the keyword initial in to (to have some initial values in the formset, such as date set to today). As far as I can tell, the queryset argument (which defaults to YourModel.objects.all()) overrides this ability for initial empty forms to be created. I specified the queryset as: YourModel.objects.none(), which prevents it from filling in the formset with entries from the database, but I still can't figure out how to pass initial in effectively. Do I need to subclass a method from ModelForm?I have a model formset that I need to pass the




你的当前访问异常,请进行认证后继续阅读剩余内容。

分享到: