Skip to content

Commit 263c726

Browse files
toolnessjkimbo
authored andcommitted
Fix code errors in form-mutations.rst (#499)
This fixes what appear to be some code errors/typos: * The `FormMutation` class was renamed to `DjangoFormMutation`, and `ModelFormMutation` to `DjangoModelFormMutation`, in 40610c6. * `form_valid` was renamed to `perform_mutate` in 463ce68. It also clarifies a few things that I found confusing: * It explicitly mentions that `perform_mutate` is a class method. * The code samples now import the form classes from their packages, so readers know where to import them from too.
1 parent 75bf398 commit 263c726

File tree

1 file changed

+12
-8
lines changed

1 file changed

+12
-8
lines changed

docs/form-mutations.rst

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,27 +4,31 @@ Integration with Django forms
44
Graphene-Django comes with mutation classes that will convert the fields on Django forms into inputs on a mutation.
55
*Note: the API is experimental and will likely change in the future.*
66

7-
FormMutation
8-
------------
7+
DjangoFormMutation
8+
------------------
99

1010
.. code:: python
1111
12+
from graphene_django.forms.mutation import DjangoFormMutation
13+
1214
class MyForm(forms.Form):
1315
name = forms.CharField()
1416
15-
class MyMutation(FormMutation):
17+
class MyMutation(DjangoFormMutation):
1618
class Meta:
1719
form_class = MyForm
1820
1921
``MyMutation`` will automatically receive an ``input`` argument. This argument should be a ``dict`` where the key is ``name`` and the value is a string.
2022

21-
ModelFormMutation
22-
-----------------
23+
DjangoModelFormMutation
24+
-----------------------
2325

24-
``ModelFormMutation`` will pull the fields from a ``ModelForm``.
26+
``DjangoModelFormMutation`` will pull the fields from a ``ModelForm``.
2527

2628
.. code:: python
2729
30+
from graphene_django.forms.mutation import DjangoModelFormMutation
31+
2832
class Pet(models.Model):
2933
name = models.CharField()
3034
@@ -61,8 +65,8 @@ Form validation
6165

6266
Form mutations will call ``is_valid()`` on your forms.
6367

64-
If the form is valid then ``form_valid(form, info)`` is called on the mutation. Override this method to change how
65-
the form is saved or to return a different Graphene object type.
68+
If the form is valid then the class method ``perform_mutate(form, info)`` is called on the mutation. Override this method
69+
to change how the form is saved or to return a different Graphene object type.
6670

6771
If the form is *not* valid then a list of errors will be returned. These errors have two fields: ``field``, a string
6872
containing the name of the invalid form field, and ``messages``, a list of strings with the validation messages.

0 commit comments

Comments
 (0)