jeudi 30 mars 2017

Django. Adding objects that have two foreign keys to the same class

my problem is that when you want to add objects to a class that contains two foreign keys to other (equal) classes. First add an object of the class to which the foreign key refers. And when you want to select the same object but in another field, it does not appear.

models.py

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

class Match(models.Model):
     home = models.ForeignKey(Team)
     away = models.ForeignKey(Team)

So .. How do I do if I want local and away to be the same teams without having to update the admin page when I create the local team?

Thanks!

Agu




Aucun commentaire:

Enregistrer un commentaire