django-spaghetti-and-meatballs icon indicating copy to clipboard operation
django-spaghetti-and-meatballs copied to clipboard

Is ManyToManyField(through='ThroughModel') supported?

Open mnieber opened this issue 3 years ago • 2 comments

I'm trying django spaghetti with these models

class Organization(Entity):
    name = models.CharField(max_length=100)


class Program(Entity):
    name = models.CharField(max_length=100)
    members = models.ManyToManyField(Organization, through="ProgramMember")


class ProgramMember(Entity):
    organization = models.ForeignKey(Organization, on_delete=models.CASCADE)
    program = models.ForeignKey(Program, on_delete=models.CASCADE)

I was expecting a diagram with Organization on the left, Program on the right, and ProgramMember in the middle connecting the two, but instead I got this:

Selection_169

Is ManyToManyField with the through keyword supported?

django==3.2.3
django-spaghetti-and-meatballs==0.4.2

mnieber avatar Jun 30 '21 04:06 mnieber

I don't think we have support for through models yet, but it shouldn't be hard.

If you look at the image, you can see there are two arrows in the red circle - And I'd guess that its drawn the connections over one another, because from a raw fields perspective, its drawing:

Program Member -> Organisation
Program Member -> Program

image

LegoStormtroopr avatar Jun 30 '21 23:06 LegoStormtroopr

Yes, there is something strange about how the lines are drawn. The blue line is drawn on top of the grey arrowheads. I think that from a raw fields perspective it's drawing

Program Member -> Organisation
Program Member -> Program
Organisation -> Program
Program -> Organisation

mnieber avatar Jul 01 '21 06:07 mnieber