mirror of
				https://github.com/django/django.git
				synced 2025-10-31 01:25:32 +00:00 
			
		
		
		
	[1.10.x] Fixed #26686 -- Fixed crash when registering model signals with abstract senders.
Backport of 08014fe75b from master
			
			
This commit is contained in:
		| @@ -1,5 +1,6 @@ | ||||
| from __future__ import unicode_literals | ||||
|  | ||||
| from django.apps.registry import Apps | ||||
| from django.db import models | ||||
| from django.db.models import signals | ||||
| from django.dispatch import receiver | ||||
| @@ -317,3 +318,14 @@ class LazyModelRefTest(BaseSignalTest): | ||||
|  | ||||
|         Created() | ||||
|         self.assertEqual(received, []) | ||||
|  | ||||
|     def test_register_model_class_senders_immediately(self): | ||||
|         """ | ||||
|         Model signals registered with model classes as senders don't use the | ||||
|         Apps.lazy_model_operation() mechanism. | ||||
|         """ | ||||
|         # Book isn't registered with apps2, so it will linger in | ||||
|         # apps2._pending_operations if ModelSignal does the wrong thing. | ||||
|         apps2 = Apps() | ||||
|         signals.post_init.connect(self.receiver, sender=Book, apps=apps2) | ||||
|         self.assertEqual(list(apps2._pending_operations), []) | ||||
|   | ||||
		Reference in New Issue
	
	Block a user