mirror of
				https://github.com/django/django.git
				synced 2025-10-31 09:41:08 +00:00 
			
		
		
		
	[3.2.x] Fixed #32332 -- Fixed loss of parent with non-numeric pk when saving child after parent.
Follow up to519016e5f2. Backport of7cba92ec55from master
This commit is contained in:
		
				
					committed by
					
						 Mariusz Felisiak
						Mariusz Felisiak
					
				
			
			
				
	
			
			
			
						parent
						
							7d65889345
						
					
				
				
					commit
					b36beec208
				
			| @@ -68,6 +68,10 @@ class Parent(models.Model): | ||||
|     bestchild = models.ForeignKey('Child', models.SET_NULL, null=True, related_name='favored_by') | ||||
|  | ||||
|  | ||||
| class ParentStringPrimaryKey(models.Model): | ||||
|     name = models.CharField(primary_key=True, max_length=15) | ||||
|  | ||||
|  | ||||
| class Child(models.Model): | ||||
|     name = models.CharField(max_length=20) | ||||
|     parent = models.ForeignKey(Parent, models.CASCADE) | ||||
| @@ -77,6 +81,10 @@ class ChildNullableParent(models.Model): | ||||
|     parent = models.ForeignKey(Parent, models.CASCADE, null=True) | ||||
|  | ||||
|  | ||||
| class ChildStringPrimaryKeyParent(models.Model): | ||||
|     parent = models.ForeignKey(ParentStringPrimaryKey, on_delete=models.CASCADE) | ||||
|  | ||||
|  | ||||
| class ToFieldChild(models.Model): | ||||
|     parent = models.ForeignKey(Parent, models.CASCADE, to_field='name', related_name='to_field_children') | ||||
|  | ||||
|   | ||||
		Reference in New Issue
	
	Block a user