Reputation: 8114
I was trying to use generic foreign key for one of my projects, I went through the django documentation, so its basically combination of content_type and object_id.
Now in my table is see that an integer value is generated for content_type_id, so my question is that how is the integer set for the content_type_id?
Upvotes: 0
Views: 573
Reputation: 3308
The number is assigned by the contentype framework. You can take a look at this by adding this to your admin.
Add these lines in any of your apps admin.py file:
from django.contrib.contenttypes.models import ContentType
class CTAdmin(admin.ModelAdmin):
list_display=('app_label','model', 'id')
admin.site.register(ContentType, CTAdmin)
Then you'll see a Contenttype app in your admin and this will show a list of all models and ids.
Upvotes: 0