X-Git-Url: http://git.ithinksw.org/philo.git/blobdiff_plain/ca2138fef978345b9076a2f855ed434a0bac65e1..ee56a2ca0d6c5d08ee42a9452de4353e8f2643ba:/forms.py?ds=sidebyside diff --git a/forms.py b/forms.py index 192d02b..b404f0d 100644 --- a/forms.py +++ b/forms.py @@ -378,4 +378,16 @@ class NodeWithOverrideForm(forms.ModelForm): return obj class Meta: - model = Node \ No newline at end of file + model = Node + + +class NodeOverrideInlineFormSet(BaseInlineFormSet): + def __init__(self, data=None, files=None, instance=None, save_as_new=False, prefix=None, queryset=None): + if queryset is None: + queryset = self.model._default_manager + queryset = queryset.filter(parent=instance, child__parent=instance) + super(NodeOverrideInlineFormSet, self).__init__(data, files, instance, save_as_new, prefix, queryset) + + def add_fields(self, form, index): + super(NodeOverrideInlineFormSet, self).add_fields(form, index) + form.fields['child'].queryset = self.instance.children.all() \ No newline at end of file