M2M with self throught int. table, how to access related items?
Hi,
I am not a django guru (yet) and I am having what I would guess a
trivial django question. 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.
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+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home