I'm trying to implement tagging using Content Types and Generic
Relationships.    What I want to is query any tagged item with a
status of Published.

All my tagged models are implementing an Abstract Model class with a
status field so they share the 'Published' and 'Unpublished' types.

Here are some cut down version of the models I'm using for an
example.    Right now I only have Posts related to Tags but I plan on
adding flat pages and such.  What I want to be able to have pages for
tags return all content with a status of Published but I don't seem to
be able to find a way to do this.  I can find content and tags just
fine but when I have to filter it further I'm stumbling and would
appreciate any insight or pointers to example code.  I've seen some
examples of custom managers online but the folks there are writing
naked SQL in the managers and I'd like to avoid going that route if I
can

class Tag(models.Model):

    text = models.CharField(max_length=30, unique=True)
    slug = models.SlugField(max_length=30, unique=True, null=True,
blank=True)


class TaggedItem(models.Model):

    tag = models.ForeignKey(Tag)

    content_type = models.ForeignKey(ContentType)
    object_id = models.PositiveIntegerField()
    content_object = generic.GenericForeignKey('content_type',
'object_id')

class Post(models.Model):

    title = models.CharField(max_length=75)
    ...
    status = models.CharField(max_length=1, choices=POST_STATUS)

    topics = generic.GenericRelation(TopicCatalog)
    tags = generic.GenericRelation(TagCatalog)

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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