If I have a django content_type reference (the id of the model.class and the id of the object), what's the best way to get the actual object itself?
Sounds trivial but I can't actually see an example anywhere.
If I have a django content_type reference (the id of the model.class and the id of the object), what's the best way to get the actual object itself?
Sounds trivial but I can't actually see an example anywhere.
From memory, it is something like this:
from django.contrib.contenttypes.models import ContentType
ct = ContentType.objects.get_for_id(content_type)
obj = ct.get_object_for_this_type(pk=object_id)