[Answer]-Have a model with an object I want to connect to two other models (Django)

1👍

You can do this:

class EventConnect(models.Model)
    events = models.ForeignKey(MyEvent)
    eventList = models.ForeignKey(Event, blank="true", null="true", related_name='event_set+')
    customEventList = models.ForeignKey(customEvent, blank="true", null="true", related_name='customevent_set+')

    class Meta:
        unique_together('events', 'Event', 'customEvent')

class MyEvent(models.Model):
    #rest of the fields..

Note that ForeignKey is sufficient in the intermediary table. You cannot assign multiple many to many against the same model field. (like assigning 2 different values to the same database column – which is not possible unless you manage the keys yourself.)

Leave a comment