lundi 6 avril 2020

Double ForeignKey Relation between Models Django

I'm a little confuse here:

class MyBirthday(Model):
    date = models.DateTimeField()
    invitations_quantity = models.IntegerField()
    message = models.CharField(max_length=500)
    user = models.ForeignKey(User)
    location = models.OneToOneField(Location)

class Attendant(Model):
    user = models.OneToOneField(User, on_delete=models.CASCADE)
    birthday_id = models.ForeignKey(MyBirthday)

The thing is whether or whether not to use the user attribute in MyBirthday model, I mean, is it okay if I just left the Attendant attribute 'birthday_id' reference it?

Aucun commentaire:

Enregistrer un commentaire