Answer the question
In order to leave comments, you need to log in
How to add a link to another model in relation to many-to-many when creating an object??
there is a model:
Class Meeting(models.Model):
name = models.CharField(max_length = 255)
Class Group(models.Model):
name = models.CharField(max_length = 255)
meeting = models.ManyToManyField(Meeting ,through=GroupMeeting)
GroupMeeting(models.Model):
meeting = models.ForeignKey(Meeting, on_delete=models.CASCADE)
group = models.ForeignKey(Group, on_delete=models.CASCADE)
Meeting
assign a link to Group
??
Answer the question
In order to leave comments, you need to log in
group = Group.objects.create(name='some_name_group')
meeting = Meeting.objects.create(name='some_meeting_name')
group.meeting.add(meeting)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question