Re: friends table adding choices from the same database

2007-07-29 Thread [EMAIL PROTECTED]

THANK YOU!

i just got home, will try this to see if this works... i'm new to
django so thanks for the help, i'll look up what related_name works,
but it looks good.

Israel

On Jul 29, 9:41 am, "[EMAIL PROTECTED]"
<[EMAIL PROTECTED]> wrote:
> If the Friend is really a user...wouldn't something like this work:
>
> class Friends(models.Model):
>  parent_user = models.ForeignKey(User, related_name="user")
>  friend_user = models.ForeignKey(User,related_name="friends")
>
> Then for the parent_user's friends...you'd do something like:
> parent_users_friends = parentuser.friends_set.all() to bring back
> a listing of all of his friends.
>
> On Jul 27, 8:05 pm, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote:
>
> > i'm working on an app that has a table called friends whose model
> > looks like this:
>
> > class Friend(models.Model):
> > user = models.ForeignKey(User)
> > friend = models.CharField(maxlength=100)
> > status = models.CharField(maxlength=1,choices=FSTATUS_CHOICES)
>
> > def __str__(self):
> > return self.friend
>
> > user is the user that added the friend, while friend SHOULD be the id
> > of the user that has been added. Both fields use the user table.  I
> > cant use the same foreign key for both, this would be an error.
> > Ideally i would want a drop down box with all the username for the
> > friend field.  I thought about using choices, but cant seem to create
> > a tuple that is dynamically populated from the username field in the
> > user table.
>
> > Any ideas how i could go about this?
>
> > P.S is this a recursive relationship? i dont think so but hopefully
> > some DB guru can shed some light.


--~--~-~--~~~---~--~~
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: friends table adding choices from the same database

2007-07-29 Thread [EMAIL PROTECTED]

If the Friend is really a user...wouldn't something like this work:

class Friends(models.Model):
 parent_user = models.ForeignKey(User, related_name="user")
 friend_user = models.ForeignKey(User,related_name="friends")

Then for the parent_user's friends...you'd do something like:
parent_users_friends = parentuser.friends_set.all() to bring back
a listing of all of his friends.



On Jul 27, 8:05 pm, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote:
> i'm working on an app that has a table called friends whose model
> looks like this:
>
> class Friend(models.Model):
> user = models.ForeignKey(User)
> friend = models.CharField(maxlength=100)
> status = models.CharField(maxlength=1,choices=FSTATUS_CHOICES)
>
> def __str__(self):
> return self.friend
>
> user is the user that added the friend, while friend SHOULD be the id
> of the user that has been added. Both fields use the user table.  I
> cant use the same foreign key for both, this would be an error.
> Ideally i would want a drop down box with all the username for the
> friend field.  I thought about using choices, but cant seem to create
> a tuple that is dynamically populated from the username field in the
> user table.
>
> Any ideas how i could go about this?
>
> P.S is this a recursive relationship? i dont think so but hopefully
> some DB guru can shed some light.


--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



friends table adding choices from the same database

2007-07-27 Thread [EMAIL PROTECTED]

i'm working on an app that has a table called friends whose model
looks like this:

class Friend(models.Model):
user = models.ForeignKey(User)
friend = models.CharField(maxlength=100)
status = models.CharField(maxlength=1,choices=FSTATUS_CHOICES)

def __str__(self):
return self.friend


user is the user that added the friend, while friend SHOULD be the id
of the user that has been added. Both fields use the user table.  I
cant use the same foreign key for both, this would be an error.
Ideally i would want a drop down box with all the username for the
friend field.  I thought about using choices, but cant seem to create
a tuple that is dynamically populated from the username field in the
user table.

Any ideas how i could go about this?

P.S is this a recursive relationship? i dont think so but hopefully
some DB guru can shed some light.


--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---