mirror of
				https://github.com/django/django.git
				synced 2025-10-31 09:41:08 +00:00 
			
		
		
		
	[1.8.x] Fixed #24613 -- Added example to QuerySet.defer() documentation
Backport of dd99f57710 from master
			
			
This commit is contained in:
		
				
					committed by
					
						 Tim Graham
						Tim Graham
					
				
			
			
				
	
			
			
			
						parent
						
							322b9c90aa
						
					
				
				
					commit
					fe533fc537
				
			| @@ -1379,6 +1379,30 @@ one, doing so will result in an error. | ||||
|     reader, is slightly faster and consumes a little less memory in the Python | ||||
|     process. | ||||
|  | ||||
|     For example, both of these models use the same underlying database table:: | ||||
|  | ||||
|         class CommonlyUsedModel(models.Model): | ||||
|             f1 = models.CharField(max_length=10) | ||||
|  | ||||
|             class Meta: | ||||
|                 managed = False | ||||
|                 db_table = 'app_largetable' | ||||
|  | ||||
|         class ManagedModel(models.Model): | ||||
|             f1 = models.CharField(max_length=10) | ||||
|             f2 = models.CharField(max_length=10) | ||||
|  | ||||
|             class Meta: | ||||
|                 db_table = 'app_largetable' | ||||
|  | ||||
|         # Two equivalent QuerySets: | ||||
|         CommonlyUsedModel.objects.all() | ||||
|         ManagedModel.objects.all().defer('f2') | ||||
|  | ||||
|     If many fields need to be duplicated in the unmanaged model, it may be best | ||||
|     to create an abstract model with the shared fields and then have the | ||||
|     unmanaged and managed models inherit from the abstract model. | ||||
|  | ||||
| .. note:: | ||||
|  | ||||
|     When calling :meth:`~django.db.models.Model.save()` for instances with | ||||
|   | ||||
		Reference in New Issue
	
	Block a user