mirror of
				https://github.com/graphql-python/graphene-django.git
				synced 2025-10-31 07:57:31 +03:00 
			
		
		
		
	Fix id lookup to handle cases where the primary key of the Django model is not called ID
This commit is contained in:
		
							parent
							
								
									31a49841ca
								
							
						
					
					
						commit
						900354837e
					
				|  | @ -98,6 +98,9 @@ class DjangoObjectTypeMeta(ObjectTypeMeta): | ||||||
| 
 | 
 | ||||||
| class DjangoObjectType(six.with_metaclass(DjangoObjectTypeMeta, ObjectType)): | class DjangoObjectType(six.with_metaclass(DjangoObjectTypeMeta, ObjectType)): | ||||||
| 
 | 
 | ||||||
|  |     def resolve_id(self, args, context, info): | ||||||
|  |         return self.pk | ||||||
|  | 
 | ||||||
|     @classmethod |     @classmethod | ||||||
|     def is_type_of(cls, root, context, info): |     def is_type_of(cls, root, context, info): | ||||||
|         if isinstance(root, cls): |         if isinstance(root, cls): | ||||||
|  | @ -112,6 +115,6 @@ class DjangoObjectType(six.with_metaclass(DjangoObjectTypeMeta, ObjectType)): | ||||||
|     @classmethod |     @classmethod | ||||||
|     def get_node(cls, id, context, info): |     def get_node(cls, id, context, info): | ||||||
|         try: |         try: | ||||||
|             return cls._meta.model.objects.get(id=id) |             return cls._meta.model.objects.get(pk=id) | ||||||
|         except cls._meta.model.DoesNotExist: |         except cls._meta.model.DoesNotExist: | ||||||
|             return None |             return None | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue
	
	Block a user