Hi,

I have tried to sent this e-mail before, but I guess it didn't make its way
to the groups so I am trying to resent it, if this is a double post, I am
sorry. I am having trouble understanding m2m relation to self with a
intermediary table. Here is my table setup stripped:

   class Post(models.Model):

       relevancy =
models.ManyToManyField("self",
through="Traffic",symmetrical=False,related_name="relevant",blank=True)

   class Traffic(models.Model):
       tfrom = models.ForeignKey(Post,related_name="tfrom")
       tto = models.ForeignKey(Post,related_name="tto")
       count = models.PositiveIntegerField(default=0)

This is to be a simple visitor tendency tool, which I keep records of
which link clicked on which post. I am confused about, getting related
items. For example, given a post, how to get set of posts which have
traffic from the post (post.tfrom_set ? ), or how to get post with a
max "count" which is trafficked to the post
( post.tto_set.max("count") ? ) etc.

And also, what is the recommended way of getting, for example, given a post,
which is the post with max "count" value from this post. Like, get a list of
traffics where tfrom is given post, and get a Traffic object with max
"count" and get tto post of that traffic.

PS: English is not my main language. Sorry if I wasn't clear

-- 
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 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.

Reply via email to