Package django :: Package contrib :: Package contenttypes :: Module models :: Class ContentTypeManager
[hide private]
[frames] | no frames]

Class ContentTypeManager

source code

db.models.Manager --+
                    |
                   ContentTypeManager

Instance Methods [hide private]
 
get_for_model(self, model)
Returns the ContentType object for a given model, creating the ContentType if necessary.
source code
 
get_for_id(self, id)
Lookup a ContentType by ID.
source code
 
clear_cache(self)
Clear out the content-type cache.
source code
 
_add_to_cache(self, ct)
Insert a ContentType into the cache.
source code
Class Variables [hide private]
  _cache = {}
Method Details [hide private]

get_for_model(self, model)

source code 

Returns the ContentType object for a given model, creating the ContentType if necessary. Lookups are cached so that subsequent lookups for the same model don't hit the database.

get_for_id(self, id)

source code 

Lookup a ContentType by ID. Uses the same shared cache as get_for_model (though ContentTypes are obviously not created on-the-fly by get_by_id).

clear_cache(self)

source code 

Clear out the content-type cache. This needs to happen during database flushes to prevent caching of "stale" content type IDs (see django.contrib.contenttypes.management.update_contenttypes for where this gets called).