Skip to content

Commit 608af57

Browse files
authored
Fix broken form.save() call in DjangoFormMutation.perform_mutate (#1155)
Django's plain (non-model) forms don't have the `save` method, so calling this would just result in an `AttributeError` before this change. Resolves #1152
1 parent 26a851a commit 608af57

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

graphene_django/forms/mutation.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,10 @@ def __init_subclass_with_meta__(
101101

102102
@classmethod
103103
def perform_mutate(cls, form, info):
104-
form.save()
104+
if hasattr(form, "save"):
105+
# `save` method won't exist on plain Django forms, but this mutation can
106+
# in theory be used with `ModelForm`s as well and we do want to save them.
107+
form.save()
105108
return cls(errors=[], **form.cleaned_data)
106109

107110

0 commit comments

Comments
 (0)