summaryrefslogtreecommitdiff
path: root/docs/ref
diff options
context:
space:
mode:
authorCarlton Gibson <carlton.gibson@noumenal.es>2025-12-11 10:05:51 +0100
committerJacob Walls <jacobtylerwalls@gmail.com>2025-12-11 12:34:43 -0500
commit37eb8909699d261b9b879e6f04dbfeec75b5e080 (patch)
tree2f0edf2dca8b969654454b2b987187343f656a56 /docs/ref
parentcd6278c4c09e4af9b2988d585b372d9abeeb63ee (diff)
Noted testing uses for ContentTypeManager.clear_cache() method.
It is often necessary to reset the cache between tests, or after preparing test state, when using content types. Django's test suite already does this when needed, but users will need to do similar in their own tests.
Diffstat (limited to 'docs/ref')
-rw-r--r--docs/ref/contrib/contenttypes.txt12
1 files changed, 10 insertions, 2 deletions
diff --git a/docs/ref/contrib/contenttypes.txt b/docs/ref/contrib/contenttypes.txt
index 9a6b14ef4c..961e454832 100644
--- a/docs/ref/contrib/contenttypes.txt
+++ b/docs/ref/contrib/contenttypes.txt
@@ -181,8 +181,16 @@ The ``ContentTypeManager``
:class:`~django.contrib.contenttypes.models.ContentType` to keep track
of models for which it has created
:class:`~django.contrib.contenttypes.models.ContentType` instances. You
- probably won't ever need to call this method yourself; Django will call
- it automatically when it's needed.
+ probably won't need to call this method in application code yourself;
+ Django will call it automatically when it's needed.
+
+ You may need to clear the cache when testing, to reset between tests,
+ or after preparing test state. For example::
+
+ class ContentTypesTests(TestCase):
+ def setUp(self):
+ ContentType.objects.clear_cache()
+ self.addCleanup(ContentType.objects.clear_cache)
.. method:: get_for_id(id)