1
0
mirror of https://github.com/django/django.git synced 2025-10-31 09:41:08 +00:00

Fixed #30368 -- Fixed prefetch_related() for GenericForeignKey when PK is also a FK.

This commit is contained in:
Vinny Do
2019-04-16 17:49:16 +10:00
committed by Mariusz Felisiak
parent d610521bff
commit a4055adf70
3 changed files with 11 additions and 0 deletions

View File

@@ -939,6 +939,9 @@ class ForeignKey(ForeignObject):
def get_db_prep_value(self, value, connection, prepared=False):
return self.target_field.get_db_prep_value(value, connection, prepared)
def get_prep_value(self, value):
return self.target_field.get_prep_value(value)
def contribute_to_related_class(self, cls, related):
super().contribute_to_related_class(cls, related)
if self.remote_field.field_name is None: