Nested Form field?
saileshkush95 opened this issue · comments
Sandeep Kushwaha commented
Prerequisites
- Is it a bug?
- [*] Is it a new feature?
- [*] Is it a a question?
- Can you reproduce the problem?
- Are you running the latest version?
- Did you check for similar issues?
- Did you perform a cursory search?
For more information, see the CONTRIBUTING guide.
Description
Thank you for this amazing package, I'm following same apprach to perform other crud operatations. and It is working fine. But I've one questions, how can i implement nested field muation and also how can i upload images. I mean simple model form works or not?
for example, I've moodel called Media, and Here is mutations for model.
class CreateMedia(
RelayMutationMixin,
DynamicInputMixin,
Output,
graphene.ClientIDMutation):
form = MediaForm
_inputs = list(form.Meta.fields)
media = graphene.Field(MediaNode)
@classmethod
@login_required
def resolve_mutation(cls, root, info, **kwargs):
f = cls.form(kwargs)
if f.is_valid():
try:
media = f.save()
return cls(success=True, media=media)
except Exception as e:
return cls(success=False, errors="Some things went wrongs")
else:
return cls(success=False, errors=f.errors.get_json_data())
and here is model
class MediaForm(forms.ModelForm):
class Meta:
model = Media
fields = ("media", "content_type", "object_id")
But it is not working