lundi 22 février 2021

self Many to many field adding when is not supossed to

class User(AbstractUser):
first_name = models.CharField(max_length=64)
last_name = models.CharField(max_length=64)
bio = models.TextField(max_length=128, blank=True)
followers = models.ManyToManyField('self', related_name='followers', blank=True)

So i have this table but when i add a user in the followers field, django also add the user in both ways. For example if i have an user called john and i want to follow a user called math. When Jhon is added to the followers of math, math is also added to the followers of jhon. And i dont know why is that. Should i use other type of model?




Aucun commentaire:

Enregistrer un commentaire