mirror of
				https://github.com/django/django.git
				synced 2025-10-31 09:41:08 +00:00 
			
		
		
		
	Fixed #32893 -- Fixed serialization of models.Model class in migrations.
Migrations assumed that an import of the models.Model class must already be included when it's serialized, but for models with only custom fields this was not necessarily the case. Thanks Jaap Joris Vens for the report.
This commit is contained in:
		
				
					committed by
					
						 Mariusz Felisiak
						Mariusz Felisiak
					
				
			
			
				
	
			
			
			
						parent
						
							36fa071d6e
						
					
				
				
					commit
					fde6fb2898
				
			| @@ -273,7 +273,7 @@ class TupleSerializer(BaseSequenceSerializer): | ||||
| class TypeSerializer(BaseSerializer): | ||||
|     def serialize(self): | ||||
|         special_cases = [ | ||||
|             (models.Model, "models.Model", []), | ||||
|             (models.Model, "models.Model", ['from django.db import models']), | ||||
|             (type(None), 'type(None)', []), | ||||
|         ] | ||||
|         for case, string, imports in special_cases: | ||||
|   | ||||
| @@ -658,6 +658,13 @@ class WriterTests(SimpleTestCase): | ||||
|     def test_serialize_type_none(self): | ||||
|         self.assertSerializedEqual(type(None)) | ||||
|  | ||||
|     def test_serialize_type_model(self): | ||||
|         self.assertSerializedEqual(models.Model) | ||||
|         self.assertSerializedResultEqual( | ||||
|             MigrationWriter.serialize(models.Model), | ||||
|             ("('models.Model', {'from django.db import models'})", set()), | ||||
|         ) | ||||
|  | ||||
|     def test_simple_migration(self): | ||||
|         """ | ||||
|         Tests serializing a simple migration. | ||||
|   | ||||
		Reference in New Issue
	
	Block a user