Let's say I have the following model classes:
# Inspection target
class Target(models.Model):
...
# Issue found during the inspection
class Issue(models.Model):
target = models.ForeignKey(Target, on_delete=models.CASCADE, related_name='issues')
So, a Target can have multiple related Issues, while an Issue always relates to one Target. Now, let's say I add a new table like this:
# Document that describes either a target or an issue
class Document(models.Model):
...
... and I want this both Targets and Issues to have references to Documents, but a single Document can only be related to one object, either a Target or an Issue. Is this possible to do with Django?