I have a question about django content_types
In the example of filtering a QuerySet for a generic content type on http://www.djangoproject.com/documentation/models/generic_relations/ there are the following lines.
ctype = ContentType.objects.get_for_model(quartz)
TaggedItem.objects.filter(content_type__pk=ctype.id, object_id=quartz.id)
Can anyone explain what content_type__pk means?
Does the __ mean that there's an indirection going on? What does that mean in the context of the left-hand side of a match in the filter?
I see that in the model definition
content_type = models.ForeignKey(ContentType)
but when translated into the database there is no field called content_type, but there is a content_type_id ... so is it that content_type__pk actually translates into content_type_id? And if so, why didn't they use this in the filter example?