mirror of
https://github.com/graphql-python/graphene-django.git
synced 2025-01-31 11:48:38 +03:00
fix choices enum: if field can be blank then it isnt required (#714)
This commit is contained in:
parent
51adb3632b
commit
b1a9293016
|
@ -73,7 +73,8 @@ def convert_django_field_with_choices(
|
||||||
return named_choices_descriptions[self.name]
|
return named_choices_descriptions[self.name]
|
||||||
|
|
||||||
enum = Enum(name, list(named_choices), type=EnumWithDescriptionsType)
|
enum = Enum(name, list(named_choices), type=EnumWithDescriptionsType)
|
||||||
converted = enum(description=field.help_text, required=not field.null)
|
required = not (field.blank or field.null)
|
||||||
|
converted = enum(description=field.help_text, required=required)
|
||||||
else:
|
else:
|
||||||
converted = convert_django_field(field, registry)
|
converted = convert_django_field(field, registry)
|
||||||
if registry is not None:
|
if registry is not None:
|
||||||
|
|
|
@ -38,7 +38,7 @@ class Reporter(models.Model):
|
||||||
last_name = models.CharField(max_length=30)
|
last_name = models.CharField(max_length=30)
|
||||||
email = models.EmailField()
|
email = models.EmailField()
|
||||||
pets = models.ManyToManyField("self")
|
pets = models.ManyToManyField("self")
|
||||||
a_choice = models.CharField(max_length=30, choices=CHOICES)
|
a_choice = models.CharField(max_length=30, choices=CHOICES, blank=True)
|
||||||
objects = models.Manager()
|
objects = models.Manager()
|
||||||
doe_objects = DoeReporterManager()
|
doe_objects = DoeReporterManager()
|
||||||
|
|
||||||
|
|
|
@ -171,7 +171,7 @@ type Reporter {
|
||||||
lastName: String!
|
lastName: String!
|
||||||
email: String!
|
email: String!
|
||||||
pets: [Reporter!]!
|
pets: [Reporter!]!
|
||||||
aChoice: ReporterAChoice!
|
aChoice: ReporterAChoice
|
||||||
reporterType: ReporterReporterType
|
reporterType: ReporterReporterType
|
||||||
articles(before: String, after: String, first: Int, last: Int): ArticleConnection
|
articles(before: String, after: String, first: Int, last: Int): ArticleConnection
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user