Limiting the sample in ManyToManyField in Django?

There are three models (tables): Product, Brand, BrandColors
Product - contains product information and communication with the brand (ForeignKey)
Brand - brand description
BrandColors - contains the colors of the brand, which he uses in his products (one brand of several records describing its color) (ForeignKey)

You need to when editing product in admin panel, you can choose several colors from the palette of the brand. To do this, decided to add a ManyToManyField to the product to communicate with BrandColors, but in the admin you can see all the colors, all brands. How to limit the list to only the colors of the brand, which is spelled out in the product?
#A shortened version of the unimportant fields and parameters removed
class Brand(models.Model):
 name = models.CharField()
 description = models.TextField()

class BrandColor(models.Model):
 brand = models.ForeignKey(Brand)
 name = models.CharField()
 color = models.CharField()

class Product(models.Model):
 brand = models.ForeignKey(Brand)
 colors = models.ManyToManyField(BrandColor)
 name = models.CharField()

We tried to limit using limit_choices_tobut came out only when explicitly specified a particular id of the brand (and it, products may be different)
# model Product
colors = models.ManyToManyField(BrandColor, limit_choices_to={'brand': 1})
July 2nd 19 at 13:09
1 answer
July 2nd 19 at 13:11

Find more questions by tags PythonDjango