Skip to content

Commit

Permalink
Merge pull request #21 from RainshawGao/patch-1
Browse files Browse the repository at this point in the history
fix required fields with default value in create mutation
  • Loading branch information
bellini666 authored Apr 21, 2021
2 parents 3ebce57 + 73f5855 commit fb7e4cf
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion graphene_django_plus/mutations.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
models,
transaction,
)
from django.db.models.fields import NOT_PROVIDED
from django.db.models.fields.reverse_related import (
ManyToOneRel,
ManyToManyRel,
Expand Down Expand Up @@ -178,7 +179,7 @@ def _get_fields(model, only_fields, exclude_fields, required_fields):
if isinstance(field, (ManyToOneRel, ManyToManyRel)):
f.kwargs["required"] = not field.null
else:
f.kwargs["required"] = not field.blank
f.kwargs["required"] = not field.blank and field.default is NOT_PROVIDED

if getattr(field, "choices", None):
items = field.choices
Expand Down

0 comments on commit fb7e4cf

Please sign in to comment.