Trying and expand the contrib.auth.user model and add a "relatipnships" manage
- by dotty
I have the following model setup.
from django.db import models
from django.contrib.auth.models import User
class SomeManager(models.Manager):
def friends(self):
# return friends bla bla bla
class Relationship(models.Model):
"""(Relationship description)"""
from_user = models.ForeignKey(User, related_name='from_user')
to_user = models.ForeignKey(User, related_name='to_user')
has_requested_friendship = models.BooleanField(default=True)
is_friend = models.BooleanField(default=False)
objects = SomeManager()
relationships = models.ManyToManyField(User, through=Relationship, symmetrical=False)
relationships.contribute_to_class(User, 'relationships')
Here i take the User object and use contribute_to_class to add 'relationships' to the User object. The relationship show up, but if call User.relationships.friends it should run the friends() method, but its failing. Any ideas how i would do this?
Thanks