im working on a social network project and im going to make follower and following to my users and i did it with another Model named Follow
class Follow(models.Model):
follower = models.ForeignKey(User,on_delete=models.CASCADE,related_name="followers", blank=False,null=False)
following = models.ForeignKey(User,on_delete=models.CASCADE,related_name="followings",blank=False,null=False)
def __str__(self):
return self.follower.username + " is following " + self.following.username
and now im gonna put conditions to record, for example somebody can't follow himself or if that record exists, don't record it again
Thanks for reading. Comments are Welcomed
Aucun commentaire:
Enregistrer un commentaire