I'm trying to create a mapping table between two generic (content_type) references, one for "agents" and one for "resources".
So I take the usual way I make a generic foreign key :
content_type = models.ForeignKey(ContentType)
object_id = models.PositiveIntegerField()
resource = generic.GenericForeignKey('content_type', 'object_id')
And I try to make a model with two.
agent_content_type = models.ForeignKey(ContentType)
agent_object_id = models.PositiveIntegerField()
agent = generic.GenericForeignKey('agent_content_type', 'agent_object_id')
resource_content_type = models.ForeignKey(ContentType)
resource_object_id = models.PositiveIntegerField()
resource = generic.GenericForeignKey('resource_content_type', 'resource_object_id')
But this now throws up the following errors :
myapp.mymodel: Accessor for field 'resource_content_type' clashes with related field 'ContentType.mymodel_set'. Add a related_name argument to the definition for 'resource_content_type'.
And similar for the agent.
What's going on here? And what should I do?
cheers
phil