django : Nested modelforms
I have two models
class Branch(models.Model):
name = ...
repository = ...
... other fields ...
class Branch_Comparison(models.Model):
name = ...
branch_from = models.ForeignKey(Branch, related_name='+')
branch_to = models.ForeignKey(Branch, related_name='+')
I would like to create a modelform for entering a new branch comparison
object.
from models import Branch_Comparison, Branch
class Branch_ComparisonForm(ModelForm):
class Meta:
model = Branch_Comparison
from django.forms.models import inlineformset_factory
InlineFormSet = inlineformset_factory(Branch_Comparison, Branch,
form=Branch_ComparisonForm)
This doesn't work.
What I am trying to achieve is the built of an input form where
branch_from and branch_to would have their own inner "ModelForm" which
would have each single Branch model parameter available.
Is that possible ?
No comments:
Post a Comment