mirror of
https://github.com/django/django.git
synced 2025-10-30 17:16:10 +00:00
[3.2.x] Fixed #32420 -- Fixed detecting primary key values in deserialization when PK is also a FK.
Backport of 8e90560aa8 from master
This commit is contained in:
committed by
Mariusz Felisiak
parent
f490cde15d
commit
d881a0ea3b
@@ -53,3 +53,17 @@ class NaturalPKWithDefault(models.Model):
|
||||
|
||||
def natural_key(self):
|
||||
return (self.name,)
|
||||
|
||||
|
||||
class FKAsPKNoNaturalKeyManager(models.Manager):
|
||||
def get_by_natural_key(self, *args, **kwargs):
|
||||
return super().get_by_natural_key(*args, **kwargs)
|
||||
|
||||
|
||||
class FKAsPKNoNaturalKey(models.Model):
|
||||
pk_fk = models.ForeignKey(NaturalKeyAnchor, on_delete=models.CASCADE, primary_key=True)
|
||||
|
||||
objects = FKAsPKNoNaturalKeyManager()
|
||||
|
||||
def natural_key(self):
|
||||
raise NotImplementedError('This method was not expected to be called.')
|
||||
|
||||
Reference in New Issue
Block a user