contenttypes.models.ContentTypeManager.clear_cache()

clear_cache() Clears an internal cache used by ContentType to keep track of models for which it has created ContentType instances. You probably won’t ever need to call this method yourself; Django will call it automatically when it’s needed.

contenttypes.models.ContentTypeManager

class ContentTypeManager ContentType also has a custom manager, ContentTypeManager, which adds the following methods: clear_cache() Clears an internal cache used by ContentType to keep track of models for which it has created ContentType instances. You probably won’t ever need to call this method yourself; Django will call it automatically when it’s needed. get_for_id(id) Lookup a ContentType by ID. Since this method uses the same shared cache as get_for_model(), it’s preferred to u

contenttypes.models.ContentType.name

name The human-readable name of the content type. This is taken from the verbose_name attribute of the model.

contenttypes.models.ContentType.model_class()

ContentType.model_class() Returns the model class represented by this ContentType instance. For example, we could look up the ContentType for the User model: >>> from django.contrib.contenttypes.models import ContentType >>> ContentType.objects.get(app_label="auth", model="user") <ContentType: user> And then use it to query for a particular User, or to get access to the User model class: >>> user_type.model_class() <class 'django.contrib.auth.models.User'

contenttypes.models.ContentType.model

model The name of the model class. Additionally, the following property is available:

contenttypes.models.ContentType.get_object_for_this_type()

ContentType.get_object_for_this_type(**kwargs) Takes a set of valid lookup arguments for the model the ContentType represents, and does a get() lookup on that model, returning the corresponding object.

contenttypes.models.ContentType.app_label

app_label The name of the application the model is part of. This is taken from the app_label attribute of the model, and includes only the last part of the application’s Python import path; “django.contrib.contenttypes”, for example, becomes an app_label of “contenttypes”.

contenttypes.models.ContentType

class ContentType Each instance of ContentType has two fields which, taken together, uniquely describe an installed model: app_label The name of the application the model is part of. This is taken from the app_label attribute of the model, and includes only the last part of the application’s Python import path; “django.contrib.contenttypes”, for example, becomes an app_label of “contenttypes”. model The name of the model class. Additionally, the following property is available:

contenttypes.forms.generic_inlineformset_factory()

generic_inlineformset_factory(model, form=ModelForm, formset=BaseGenericInlineFormSet, ct_field="content_type", fk_field="object_id", fields=None, exclude=None, extra=3, can_order=False, can_delete=True, max_num=None, formfield_callback=None, validate_max=False, for_concrete_model=True, min_num=None, validate_min=False) Returns a GenericInlineFormSet using modelformset_factory(). You must provide ct_field and fk_field if they are different from the defaults, content_type and object_id respec

contenttypes.forms.BaseGenericInlineFormSet

class BaseGenericInlineFormSet