mirror of
				https://github.com/graphql-python/graphene-django.git
				synced 2025-11-04 01:47:57 +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]
 | 
			
		||||
 | 
			
		||||
        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:
 | 
			
		||||
        converted = convert_django_field(field, registry)
 | 
			
		||||
    if registry is not None:
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -38,7 +38,7 @@ class Reporter(models.Model):
 | 
			
		|||
    last_name = models.CharField(max_length=30)
 | 
			
		||||
    email = models.EmailField()
 | 
			
		||||
    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()
 | 
			
		||||
    doe_objects = DoeReporterManager()
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -171,7 +171,7 @@ type Reporter {
 | 
			
		|||
  lastName: String!
 | 
			
		||||
  email: String!
 | 
			
		||||
  pets: [Reporter!]!
 | 
			
		||||
  aChoice: ReporterAChoice!
 | 
			
		||||
  aChoice: ReporterAChoice
 | 
			
		||||
  reporterType: ReporterReporterType
 | 
			
		||||
  articles(before: String, after: String, first: Int, last: Int): ArticleConnection
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue
	
	Block a user