From f04af7080b12744c8f06fb8228ef683d556690d0 Mon Sep 17 00:00:00 2001 From: Alex Gaynor Date: Wed, 12 Oct 2011 20:51:59 +0000 Subject: Introduce `ContentType.objects.get_for_models(*models)` and use it in the the auth permissions code. This is a solid performance gain on the test suite. Thanks to ptone for the profiling to find this hotspot, and carl for the review. git-svn-id: http://code.djangoproject.com/svn/django/trunk@16963 bcc190cf-cafb-0310-a4f2-bffc1f526a37 --- docs/ref/contrib/contenttypes.txt | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'docs') diff --git a/docs/ref/contrib/contenttypes.txt b/docs/ref/contrib/contenttypes.txt index 914e06115b..fc685c8cd6 100644 --- a/docs/ref/contrib/contenttypes.txt +++ b/docs/ref/contrib/contenttypes.txt @@ -193,6 +193,13 @@ The ``ContentTypeManager`` :class:`~django.contrib.contenttypes.models.ContentType` instance representing that model. + .. method:: get_for_models(*models) + + Takes a variadic number of model classes, and returns a dictionary + mapping the model classes to the + :class:`~django.contrib.contenttypes.models.ContentType` instances + representing them. + .. method:: get_by_natural_key(app_label, model) Returns the :class:`~django.contrib.contenttypes.models.ContentType` @@ -319,8 +326,8 @@ creating a ``TaggedItem``:: Due to the way :class:`~django.contrib.contenttypes.generic.GenericForeignKey` is implemented, you cannot use such fields directly with filters (``filter()`` -and ``exclude()``, for example) via the database API. Because a -:class:`~django.contrib.contenttypes.generic.GenericForeignKey` isn't a +and ``exclude()``, for example) via the database API. Because a +:class:`~django.contrib.contenttypes.generic.GenericForeignKey` isn't a normal field objects, these examples will *not* work:: # This will fail -- cgit v1.3