Re: Many to Many entries being duplicated, any ideas?

2008-12-09 Thread Darthmahon

I'll give it a go :) Thanks for your help Ben.

On Dec 9, 9:50 am, Ben Eliott <[EMAIL PROTECTED]> wrote:
> hmm, don't know. that's the documented approach. you might want to  
> investigate intermediary tables/models etc.
>
> On 9 Dec 2008, at 09:24, Darthmahon wrote:
>
>
>
> > Ahh yes possibly. Any downsides to using this?
>
> > On Dec 9, 9:19 am, Ben Eliott <[EMAIL PROTECTED]> wrote:
> >> 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 django-users@googlegroups.com
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
-~--~~~~--~~--~--~---



Re: Many to Many entries being duplicated, any ideas?

2008-12-09 Thread Ben Eliott

hmm, don't know. that's the documented approach. you might want to  
investigate intermediary tables/models etc.


On 9 Dec 2008, at 09:24, Darthmahon wrote:

>
> Ahh yes possibly. Any downsides to using this?
>
> On Dec 9, 9:19 am, Ben Eliott <[EMAIL PROTECTED]> wrote:
>> 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 django-users@googlegroups.com
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
-~--~~~~--~~--~--~---



Re: Many to Many entries being duplicated, any ideas?

2008-12-09 Thread Darthmahon

Ahh yes possibly. Any downsides to using this?

On Dec 9, 9:19 am, Ben Eliott <[EMAIL PROTECTED]> wrote:
> 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 django-users@googlegroups.com
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
-~--~~~~--~~--~--~---



Re: Many to Many entries being duplicated, any ideas?

2008-12-09 Thread Ben Eliott

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 django-users@googlegroups.com
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
-~--~~~~--~~--~--~---



Re: Many to Many entries being duplicated, any ideas?

2008-12-09 Thread Darthmahon

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 django-users@googlegroups.com
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
-~--~~~~--~~--~--~---



Many to Many entries being duplicated, any ideas?

2008-12-08 Thread Darthmahon

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 django-users@googlegroups.com
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
-~--~~~~--~~--~--~---