November 2015
Beginner to intermediate
840 pages
26h 30m
English
contenttypes and Generic RelationsBy default, Django includes the contenttypes contributed app in every new project, as shown in Example 20.1.
Example 20.1: Project Code
suorganizer/settings.py in 97c4234a4a
35 INSTALLED_APPS = ( . ... 38 'django.contrib.contenttypes', . ... 48 )
The app keeps track of all of the types of content in our project, as shown in Example 20.2.
Example 20.2: Python Interpreter Code
>>> from django.contrib.contenttypes.models import ContentType >>> ContentType.objects.all() [<ContentType: log entry>, <ContentType: permission>, <ContentType: group>, <ContentType: user>, <ContentType: content type>, <ContentType: ...
Read now
Unlock full access