Hay I've got a question about relationships.
I want to Users to have Friendships. So a User can be a friend with another User. I'm assuming i'll need to use the ManyToManyField, through a Friendship table. But i cannot get it to work. Any ideas?
Here are my models.
class User(models.Model):
username = models.CharField(max_length=999)
password = models.CharField(max_length=999)
created_on = models.DateField(auto_now = False, auto_now_add = True)
updated_on = models.DateField(auto_now = True, auto_now_add = False)
friends = models.ManyToManyField('self')
pendingFriends = models.ManyToManyField('self', through='PendingFriendship', symmetrical=False, related_name='friend_requested')
class PendingFriendship(models.Model):
user = models.ForeignKey('User', related_name='user')
requested_friend = models.ForeignKey('User', related_name='requested_friend')
created_on = models.DateField(auto_now = False, auto_now_add = True)
updated_on = models.DateField(auto_now = True, auto_now_add = False)
Thanks