I run into the problem of clashing automatic related names, and often having a foreign manager installed on the related model is not needed.
For example, it would be great if i could:
class ExtraWidgetThingy(models.Model):
product = models.ForeignKey("product.Product")
also_tastes_good_with = models.ForeignKey(
"product.Product", related_name=None)
instead of related_name='extrawidgetthingys_that_also_tastes_good_with_this'
The related_name attribute specifies the name of the reverse relation from the User model back to your model. If you don't specify a related_name, Django automatically creates one using the name of your model with the suffix _set.
Your intermediate model must contain one - and only one - foreign key to the source model (this would be Group in our example), or you must explicitly specify the foreign keys Django should use for the relationship using ManyToManyField.
Django automatically creates an index for all models. ForeignKey columns. From Django documentation: A database index is automatically created on the ForeignKey .
From the docs:
If you'd prefer Django didn't create a backwards relation, set
related_name
to'+'
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With