1
You can use a simple CharField
with choices to assign an entry to a specific container:
class Entry(models.Model):
REFERENCE = 'reference'
BACKBURNER = 'backburner-item'
ACTION_STEP = 'action-step'
CONTAINER_CHOICES = (
(REFERENCE, 'Reference'),
(BACKBURNER, 'Backburner item'),
(ACTION_STEP, 'Action step'),
)
container = models.CharField(choices=CONTAINER_CHOICES)
project = models.ForeignKey('Project', on_delete=models.CASCADE)
...
You can easily query for entries belonging to a specific container, either from a Project
instance or from the Entry
class:
references = project.entry_set.filter(container=Entry.REFERENCE)
Source:stackexchange.com