擅长:python、mysql、java
<p>必须有两个表的关联实体。你知道吗</p>
<pre><code>class ball(models.Model):
code_ball=models.CharField(max_length=150,unique=True)
description_ball = models.CharField(max_length=254)
made_country_ball= models.CharField(max_length=254)
f_ball= models.CharField(max_length=254)
rel= models.ManyToManyField(stadium, through='StadiumBall')
class stadium(models.Model):
code_stadium=models.CharField(max_length=150,unique=True)
description_stadium = models.CharField(max_length=254)
made_country_stadium= models.CharField(max_length=254)
andress_stadium= models.CharField(max_length=254)
team_stadium= models.CharField(max_length=254)
class StadiumBall(models.Model):
stadium = models.ForeignKey(stadium, on_delete=models.CASCADE)
ball = models.ForeignKey(ball, on_delete=models.CASCADE)
</code></pre>
<p><a href="https://docs.djangoproject.com/en/2.1/ref/models/fields/#manytomanyfield" rel="nofollow noreferrer">Here is a documentation</a></p>