T
T
tarp202021-06-10 11:02:45
Django
tarp20, 2021-06-10 11:02:45

How to organize django model?

There is a FastApi model

class GroupInfo(BaseModel):
    group_id: int
    name: str

you need to create a similar model in django:

and what would refer to the model
class Meeting(models.Model):
   start_date = models.DateTimeField(
        default=timezone.localtime,
    )
    end_date = models.DateTimeField(
        default=timezone.localtime,
    )


and that would GroupInfohave many references to meeting, but meeting was attributed to only 1 GroupInfo

class  GroupInfo(models.Model):
    
    meeting = models.ManyToManyField(Meeting)
    group_id = models.IntegerField()
    name = models.CharField(max_length=255)

Answer the question

In order to leave comments, you need to log in

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

What a duplicate question

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question