[Django]-Django: need help with keeping apps from depending on one another

0👍

Here’s what I have so far that seems to be working:

class AccountGroup(models.Model):
    accounts = models.ManyToManyField(Account)
    content_type = models.ForeignKey(ContentType)
    object_id = models.PositiveIntegerField()
    content_object = generic.GenericForeignKey('content_type', 'object_id')

Documented here. This way accounts can be grouped together by anything they have in common in outside apps. In my case, when I create an account group, I set content_type to family, and object_id to the particular family instance it should be grouped by. The view is a simple wrapped generic view.

Leave a comment