Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Why DjangoFormMutation.perform_mutate() calls form.save() #1152

Closed
ruohola opened this issue Mar 24, 2021 · 3 comments · Fixed by #1155
Closed

Why DjangoFormMutation.perform_mutate() calls form.save() #1152

ruohola opened this issue Mar 24, 2021 · 3 comments · Fixed by #1155
Labels

Comments

@ruohola
Copy link
Contributor

ruohola commented Mar 24, 2021

Django's plain (non-model) Forms don't have the save() method. Why does DjangoFormMutation.perform_mutate() still call that here:

Am I missing something or does this just always end up in an error?

@zbyte64
Copy link
Collaborator

zbyte64 commented Mar 25, 2021

You're correct. That should probably be part of the DjangoModelFormMutation instead

@ruohola
Copy link
Contributor Author

ruohola commented Mar 25, 2021

You're correct. That should probably be part of the DjangoModelFormMutation instead

Yeah, it is there:

@classmethod
def perform_mutate(cls, form, info):
obj = form.save()
kwargs = {cls._meta.return_field_name: obj}
return cls(errors=[], **kwargs)
and I think it should only be there.

@ruohola
Copy link
Contributor Author

ruohola commented Apr 5, 2021

Made a PR for this, @zbyte64 could you review?

zbyte64 pushed a commit that referenced this issue Apr 11, 2021
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants