[Fixed]-Django Models Generic Relations

1๐Ÿ‘

โœ…

As you mentioned that you need to link comment back to either Workflow/WorkflowItem, I believe you can structure your models as below

class Workflow(models.Model):
    members M2M field

class WorkflowItem(models.Model):
    fields

class Comment(models.Model):
    name_of_your_generic_fk(Can be either Workflow/WorkflowItem or any content type for that matter)
    fields

Using models structure like this you can trace from comment if it was made on Workflow/WorkflowItem.

You can obviously devise a better solution if you put more thought into it!! ๐Ÿ™‚

Leave a comment