How to limit number of foreignKey?

Stupid of course, I can count the number of foreignkey in the table for a particular user, but that every time an extra query.
Is there a more elegant way to limit the number of such links?
Say to the Field "User" you want to take a maximum of 15 keys
April 7th 20 at 10:48
1 answer
April 7th 20 at 10:50
example write
There are 2 models
UserHero and UserInvHelmet

In UserInvHelmet I want to store a maximum of 20 objects belonging to UserHero

class UserInvHelmet(models.Model):
 inv_helmet = models.ForeignKey(UserHero,on_delete=models.CASCADE)
- lindsay65 commented on April 7th 20 at 10:53
forces the ORM does, only superficially

you can play with the Super method, but it is a perversion - sandra commented on April 7th 20 at 10:56

Find more questions by tags Django