mirror of
https://github.com/django/django.git
synced 2025-08-04 02:48:35 +00:00
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
This commit is contained in:
parent
a5e691e5de
commit
f04af7080b
4 changed files with 96 additions and 10 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue