Do you want something like this?
friends_new = models.ManyToManyField("self",symmetrical=False)
On 9 Dec 2008, at 09:06, Darthmahon wrote:
>
> Hi Guys,
>
> Just bumping this up as I still can't figure out why this is
> happening :/
>
> On Dec 8, 9:27 pm, Darthmahon <[EMAIL PROTECTED]> wrote:
>> Hi Guys,
>>
>> I've got a model that has a Many to Many relationship on one of the
>> fields. This relationship is basically on itself though like this:
>>
>> #####################
>>
>> class UserProfile(models.Model):
>>
>> user = models.ForeignKey(User,
>> unique=True)
>> friends_new = models.ManyToManyField('UserProfile',
>> blank=True,
>> related_name='friend_set_new')
>>
>> #####################
>>
>> I'm trying to "add" to the friends_new field using this code:
>>
>> #####################
>>
>> # get users
>> initiator_profile = UserProfile.objects.get(user=request.user.id)
>> recipient_profile = UserProfile.objects.get(user=username)
>>
>> # now add them as a friend
>> initiator_profile.friends_new.add(recipient_profile)
>>
>> #####################
>>
>> Now the problem I'm having is that it is adding the friendship to
>> BOTH
>> userprofiles, initiator and recipient. And when I try to remove the
>> relationship, again it removes BOTH. So in the database it has two
>> entries when I only expect there to be one.
>>
>> Hope I've made that clear enough, any ideas how to get around this?
>>
>> Cheers,
>> Chris
> >
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---