Answer the question
In order to leave comments, you need to log in
How to get object from Many-To-Many Field?
I have models:
class Position(models.Model):
name = models.CharField(max_length=50, unique=True, default=None, blank=False, null=False)
class Team(models.Model):
city = models.ForeignKey(City, null=True, on_delete=models.DO_NOTHING)
position = models.ForeignKey(Position, null=True, on_delete=models.CASCADE)
class Game(models.Model):
gameId = models.IntegerField(default=0, blank=False, null=False) # не id
team = models.ManyToManyField(to=Team)
class City(models.Model):
name = models.CharField(default=None, unique=True, max_length=50, blank=False, null=False)
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question