How do I do queries when ContentType is involved?
Using the example in the doc (
http://docs.djangoproject.com/en/dev/ref/contrib/contenttypes/#id1
)
class TaggedItem(models.Model):
tag = models.SlugField()
content_type = models.ForeignKey(ContentType)
object_id = models.PositiveIntegerField()
content_object = generic.GenericForeignKey('content_type',
'object_id')
class Bookmark(models.Model):
url = models.URLField()
tags = generic.GenericRelation(TaggedItem)
So say I attached a bunch of tags to a bunch of bookmarks.
How do I get a list of all bookmarks that have the tag "django"?
Also what kind of SQL statements are generated behind the scene to
enable this querying over generic relations?
Say I have many different classes (e.g. Bookmark, ForumPost,
WikiEntry, QnA, Message, Photo, etc) that I want to attach tags to.
If I want to find all the bookmarks, forum posts, wiki entries, Q&A,
messages, photos, etc that have the tag "django", can I do it in 1
statement or would I have to do it separately for each class?
Thanks
--
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group, send email to [email protected].
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=.