1 from django
.db
import models
2 from django
.contrib
.contenttypes
.models
import ContentType
3 from django
.utils
.encoding
import force_unicode
5 class CommentManager(models
.Manager
):
7 def in_moderation(self
):
9 QuerySet for all comments currently in the moderation queue.
11 return self
.get_query_set().filter(is_public
=False, is_removed
=False)
13 def for_model(self
, model
):
15 QuerySet for all comments for a particular model (either an instance or
18 ct
= ContentType
.objects
.get_for_model(model
)
19 qs
= self
.get_query_set().filter(content_type
=ct
)
20 if isinstance(model
, models
.Model
):
21 qs
= qs
.filter(object_pk
=force_unicode(model
._get
_pk
_val
()))