mirror of
				https://github.com/graphql-python/graphene-django.git
				synced 2025-11-04 09:57:53 +03:00 
			
		
		
		
	Fix broken form.save() call in DjangoFormMutation.perform_mutate
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
This commit is contained in:
		
							parent
							
								
									80ea51fc3b
								
							
						
					
					
						commit
						26c4924e3a
					
				| 
						 | 
				
			
			@ -101,7 +101,10 @@ class DjangoFormMutation(BaseDjangoFormMutation):
 | 
			
		|||
 | 
			
		||||
    @classmethod
 | 
			
		||||
    def perform_mutate(cls, form, info):
 | 
			
		||||
        form.save()
 | 
			
		||||
        if hasattr(form, "save"):
 | 
			
		||||
            # `save` method won't exist on plain Django forms, but this mutation can
 | 
			
		||||
            # in theory be used with `ModelForm`s as well and we do want to save them.
 | 
			
		||||
            form.save()
 | 
			
		||||
        return cls(errors=[], **form.cleaned_data)
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue
	
	Block a user