mirror of
				https://github.com/graphql-python/graphene.git
				synced 2025-10-30 23:47:55 +03:00 
			
		
		
		
	Adding comments to filter_for_reverse_field()
This commit is contained in:
		
							parent
							
								
									64ec0ca94f
								
							
						
					
					
						commit
						be6b2bf290
					
				|  | @ -58,14 +58,22 @@ class GrapheneFilterSetMixin(object): | ||||||
| 
 | 
 | ||||||
|     @classmethod |     @classmethod | ||||||
|     def filter_for_reverse_field(cls, f, name): |     def filter_for_reverse_field(cls, f, name): | ||||||
|  |         """Handles retrieving filters for reverse relationships | ||||||
|  | 
 | ||||||
|  |         We override the default implementation so that we can handle | ||||||
|  |         Global IDs (the default implementation expects database | ||||||
|  |         primary keys) | ||||||
|  |         """ | ||||||
|         rel = f.field.rel |         rel = f.field.rel | ||||||
|         default = { |         default = { | ||||||
|             'name': name, |             'name': name, | ||||||
|             'label': capfirst(rel.related_name) |             'label': capfirst(rel.related_name) | ||||||
|         } |         } | ||||||
|         if rel.multiple: |         if rel.multiple: | ||||||
|  |             # For to-many relationships | ||||||
|             return GlobalIDMultipleChoiceFilter(**default) |             return GlobalIDMultipleChoiceFilter(**default) | ||||||
|         else: |         else: | ||||||
|  |             # For to-one relationships | ||||||
|             return GlobalIDFilter(**default) |             return GlobalIDFilter(**default) | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue
	
	Block a user