Tuesday, November 22, 2011

Multiple references to same field

Hi,

I am wondering if I can dynamically add multiple references to a same field in a django model. Let's say I have this model:

class Entry(models.Model)
    parent = models.ForeignKey('Entry', null = True, related_name = 'children')
    ...

entry = Entry.objects.get(id=0)

Now, I want entry.post to be entry.parent. But I also want to be able to filter by the "virtual" field post. Say Entry.objects.get(post__id__in=[something])

Is this possible at all?

Thanks and cheers!

--
--
Dejan Noveski

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

No comments:

Post a Comment