List Info

Thread: How to handle person to person relationships




How to handle person to person relationships
user name
2006-08-29 14:01:40
How code the relationship like
"a person has many friends"

code so far.

class Person(models.Model):
    full_name = models.CharField(maxlength=100)
    nick_name = models.CharField(maxlength=20)
    about = models.TextField(blank=True)
    sex = models.CharField(maxlength=1, choices=SEXES)

    # contact is also a person object so it is a reference
to same
person
    # more study needs to be done on how to add attributes
to
ManyToMany relationship in Django
    # e.g. we may need to define whether a contact is my
friend etc.
    # creating a separate class for Contact may not be the a
good
solution, since a Contact is also a Person
    contacts = models.ManyToManyField('self')


Or like this

class PersonRelation(models.Model):
    person = models.ForeignKey(Person)
    relations = models.ManyToManyField(Person, related_name
=
'friends')
    type = models.IntegerField(choices=FRIEND_TYPES)
    group = models.IntegerField(choices=GROUP_TYPES)



please highlight pros and cons.


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the
Google Groups "Django users" group.
To post to this group, send email to django-usersgooglegroups.com
To unsubscribe from this group, send email to
django-users-unsubscribegooglegroups.com
For more options, visit this group at http://gr
oups.google.com/group/django-users
-~----------~----~----~----~------~----~------~--~---

How to handle person to person relationships
user name
2006-08-29 14:35:46
http://www.djangoproject.com/documentation/model
s/m2m_recursive/


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the
Google Groups "Django users" group.
To post to this group, send email to django-usersgooglegroups.com
To unsubscribe from this group, send email to
django-users-unsubscribegooglegroups.com
For more options, visit this group at http://gr
oups.google.com/group/django-users
-~----------~----~----~----~------~----~------~--~---

How to handle person to person relationships
user name
2006-08-29 17:18:37
I have already gone through that. but problem is that I need
to add
some attributes to relationships like

he is my best friend
i have not met him

something like orkut.


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the
Google Groups "Django users" group.
To post to this group, send email to django-usersgooglegroups.com
To unsubscribe from this group, send email to
django-users-unsubscribegooglegroups.com
For more options, visit this group at http://gr
oups.google.com/group/django-users
-~----------~----~----~----~------~----~------~--~---

How to handle person to person relationships
user name
2006-08-29 17:56:35
On 8/29/06, Mir Nazim <mirnazimgmail.com> wrote:
>
> I have already gone through that. but problem is that I
need to add
> some attributes to relationships like
>
> he is my best friend
> i have not met him
>
> something like orkut.

If you're going to attach view and template behavior based
on the
different relationship types as you add them, then I think
it makes
sense to just have a separate attribute field on the Person
model for
each relationship type.

class Person(models.Model):
...
   contacts = models.ManyToManyField('self')
   friends = models.ManyToManyField('self')
   enemies = models.ManyToManyField('self')

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the
Google Groups "Django users" group.
To post to this group, send email to django-usersgooglegroups.com
To unsubscribe from this group, send email to
django-users-unsubscribegooglegroups.com
For more options, visit this group at http://gr
oups.google.com/group/django-users
-~----------~----~----~----~------~----~------~--~---

How to handle person to person relationships
user name
2006-08-30 17:41:09

Jeremy Dunck wrote:
> On 8/29/06, Mir Nazim <mirnazimgmail.com> wrote:
> >
> > I have already gone through that. but problem is
that I need to add
> > some attributes to relationships like
> >
> > he is my best friend
> > i have not met him
> >
> > something like orkut.
>
> If you're going to attach view and template behavior
based on the
> different relationship types as you add them, then I
think it makes
> sense to just have a separate attribute field on the
Person model for
> each relationship type.
>
> class Person(models.Model):
> ...
>    contacts = models.ManyToManyField('self')
>    friends = models.ManyToManyField('self')
>    enemies = models.ManyToManyField('self')

Yes you are right, Jermy,

That is the approach we are taking now. actually now it will
be only
contacts field. All ther classification will be handled
using a generic
taxonomy system(taging).

Now comes another problem, I have read generic relationships
document
at django site. but can anyone point me to some urls where
thing like
content-type etc(that are need for generic relationship to
work)
described in detail. The solution defined in that document
http://www.djangoproject.com/documentation/m
odels/generic_relations/
seem cool and usable. just need to understand the background
more

Regards
Mir Nazim


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the
Google Groups "Django users" group.
To post to this group, send email to django-usersgooglegroups.com
To unsubscribe from this group, send email to
django-users-unsubscribegooglegroups.com
For more options, visit this group at http://gr
oups.google.com/group/django-users
-~----------~----~----~----~------~----~------~--~---

How to handle person to person relationships
user name
2006-08-30 18:07:02
On 8/30/06, Mir Nazim <mirnazimgmail.com> wrote:
> Now comes another problem, I have read generic
relationships document
> at django site. but can anyone point me to some urls
where thing like
> content-type etc(that are need for generic relationship
to work)
> described in detail. The solution defined in that
document
> http://www.djangoproject.com/documentation/m
odels/generic_relations/
> seem cool and usable. just need to understand the
background more

django.contrib.comments uses contenttype pretty extensively:
http://code.djangoproject.com/browser/
django/trunk/django/contrib/comments

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the
Google Groups "Django users" group.
To post to this group, send email to django-usersgooglegroups.com
To unsubscribe from this group, send email to
django-users-unsubscribegooglegroups.com
For more options, visit this group at http://gr
oups.google.com/group/django-users
-~----------~----~----~----~------~----~------~--~---

How to handle person to person relationships
user name
2006-08-30 18:20:44
I know that but my problem is that it is still undocumented.
I am an
absolute newbie in case of django and web development in
python.
Though I have used python for quite some time.

CAn you provide some link that documents content-type
system.

On 8/30/06, Jeremy Dunck <jdunckgmail.com> wrote:
>
> On 8/30/06, Mir Nazim <mirnazimgmail.com> wrote:
> > Now comes another problem, I have read generic
relationships document
> > at django site. but can anyone point me to some
urls where thing like
> > content-type etc(that are need for generic
relationship to work)
> > described in detail. The solution defined in that
document
> > http://www.djangoproject.com/documentation/m
odels/generic_relations/
> > seem cool and usable. just need to understand the
background more
>
> django.contrib.comments uses contenttype pretty
extensively:
> http://code.djangoproject.com/browser/
django/trunk/django/contrib/comments
>
> >
>


-- 
--------------------
MA SALAAM
------------------------------------------------------------
---------
 Mir Nazim       http://mirnazim.wordpre
ss.com
------------------------------------------------------------
---------
 XenSoft Labs    http://www.xensoftlabs.com

------------------------------------------------------------
---------

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the
Google Groups "Django users" group.
To post to this group, send email to django-usersgooglegroups.com
To unsubscribe from this group, send email to
django-users-unsubscribegooglegroups.com
For more options, visit this group at http://gr
oups.google.com/group/django-users
-~----------~----~----~----~------~----~------~--~---

[1-7]

about | contact  Other archives ( Real Estate discussion Medical topics )