K
K
kieko2021-06-10 12:28:14
Django
kieko, 2021-06-10 12:28:14

How to implement this model?

there is a class:

class Meeting(models.Model):
    name = models.CharField(max_length = 255)


How to create a GroupMeeting model that can be assigned to many Meetingand one Meetingcan only have one GroupMeeting:

how to implement this model without modification Meeting!?

class GroupMeeting ( models . Model ):
    meeting = models . ForeignKey ( Meeting , on_delete = models.SET_NULL 
    group_id = models . IntegerField () 
    name = models . CharField ( max_length = 255 )


since in this case it GroupMeetingis connected with one Meeting , but Meetingconnected with many GroupMeeting

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Denis Melnikov, 2021-06-10
@Mi11er

Somehow you contradict yourself
GroupMeeting can have many Meetings
and Meeting Only one group ..
So if I choose 1 meeting for 2 different groups, then it turns out that the meeting will already have 2 groups ...
I see only through
group = models.ForeignKey(GroupMeeting....)
Maybe someone else will have ideas

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question