summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/modeltests/proxy_models/models.py7
-rw-r--r--tests/regressiontests/defer_regress/models.py10
2 files changed, 17 insertions, 0 deletions
diff --git a/tests/modeltests/proxy_models/models.py b/tests/modeltests/proxy_models/models.py
index 275b5207cc..ab381129cf 100644
--- a/tests/modeltests/proxy_models/models.py
+++ b/tests/modeltests/proxy_models/models.py
@@ -5,6 +5,7 @@ than using a new table of their own. This allows them to act as simple proxies,
providing a modified interface to the data from the base class.
"""
+from django.contrib.contenttypes.models import ContentType
from django.db import models
@@ -171,6 +172,12 @@ FieldError: Proxy model 'NoNewFields' contains model fields.
[<OtherPerson: barney>, <OtherPerson: fred>]
>>> OtherPerson._default_manager.all()
[<OtherPerson: barney>, <OtherPerson: wilma>]
+
+# A proxy has the same content type as the model it is proxying for (at the
+# storage level, it is meant to be essentially indistinguishable).
+>>> ctype = ContentType.objects.get_for_model
+>>> ctype(Person) is ctype(OtherPerson)
+True
"""}
diff --git a/tests/regressiontests/defer_regress/models.py b/tests/regressiontests/defer_regress/models.py
index e2a5944f92..11ce1557fe 100644
--- a/tests/regressiontests/defer_regress/models.py
+++ b/tests/regressiontests/defer_regress/models.py
@@ -3,6 +3,7 @@ Regression tests for defer() / only() behavior.
"""
from django.conf import settings
+from django.contrib.contenttypes.models import ContentType
from django.db import connection, models
class Item(models.Model):
@@ -91,5 +92,14 @@ u'c1'
>>> Leaf.objects.select_related().only("child__name", "second_child__name")
[<Leaf_Deferred_name_value: l1>]
+Models instances with deferred fields should still return the same content
+types as their non-deferred versions (bug #10738).
+>>> ctype = ContentType.objects.get_for_model
+>>> c1 = ctype(Item.objects.all()[0])
+>>> c2 = ctype(Item.objects.defer("name")[0])
+>>> c3 = ctype(Item.objects.only("name")[0])
+>>> c1 is c2 is c3
+True
+
"""
}