我最后犯了一个错误:
metaclass conflict: the metaclass of a derived class must be a (non-strict) subclass of the metaclasses of all its bases
我唯一改变的是传递一个参数来过滤查询集。医生说了一个更简单的例子。你知道吗
你知道吗表单.py: 你知道吗
class BaseEducationFormSet(BaseModelFormSet):
def __init__(self, *args, **kwargs):
id = kwargs.pop('curriculum_fk')
super().__init__(*args, **kwargs)
self.queryset = Education.objects.filter(curriculum__id=id)
你知道吗视图.py: 你知道吗
def cv_edit(request, pk):
EducationFormSet = modelformset_factory(Education, fields = ('title', 'institution', 'place') , formset=BaseEducationFormSet(curriculum_fk=pk))
我以为“模型工厂”能处理这项工作。。。你知道吗
嗯,我想我的问题的答案是使用“BaseInlineFormSet”对象和他自己的工厂。你知道吗
这将在后面的django doc中描述
相关问题 更多 >
编程相关推荐