summaryrefslogtreecommitdiff
path: root/docs
diff options
context:
space:
mode:
authorRichard Eames <github@naddiseo.ca>2015-04-21 21:42:50 -0600
committerTim Graham <timograham@gmail.com>2015-04-22 19:19:17 -0400
commitfe533fc537e8eecd9ad592b140387f44d21727ab (patch)
tree9d0864af87f8f2f85eb9a127faccae875195637f /docs
parent322b9c90aa3f29dd658686b0689d718d8a8b463d (diff)
[1.8.x] Fixed #24613 -- Added example to QuerySet.defer() documentation
Backport of dd99f57710bb4930561a6c049f54719af80850ec from master
Diffstat (limited to 'docs')
-rw-r--r--docs/ref/models/querysets.txt24
1 files changed, 24 insertions, 0 deletions
diff --git a/docs/ref/models/querysets.txt b/docs/ref/models/querysets.txt
index f4609b0081..e6e2335040 100644
--- a/docs/ref/models/querysets.txt
+++ b/docs/ref/models/querysets.txt
@@ -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