-
Notifications
You must be signed in to change notification settings - Fork 10
Open
Description
Entangled Form is working great so far, consider below models.py
models.py
class Customer(models.Model):
name = forms.CharField(max_length=255)
address = forms.JsonField()
The out put i am looking forward to is
{'name ': 'john doe', 'address': [ {'city': 'zxc', 'zipcode': 'zxc'}, {'city': 'zxc', 'zipcode': 'zxc'} ] }
Is there a way to get above output using entangled forms?
I tried to combine entangled forms with formset_factory()
below is output i am getting when combine with formset_factory()
[{'name ': 'john doe', 'address': {'city': 'zxc', 'zipcode': 'zxc'} }, {'name ': 'john doe', 'address': {'city': 'zxc', 'zipcode': 'zxc'} }, {'name ': 'john doe', 'address': {'city': 'zxc', 'zipcode': 'zxc'} }]
forms.py
class testForm(EntangledModelForm):
city = forms.CharField(max_length=255, required=True)
zipcode = forms.CharField(max_length=34, required=True)
class Meta:
model = Customer
entangled_fields = {"address": ['city', 'zipcode'] }
untangled_fields = ['name']
testFormSet = formset_factory(testForm, extra=1)
nikolas-dev
Metadata
Metadata
Assignees
Labels
No labels