fromdjango.dbimportmodelsfromdjango.contribimportadminfromdjango.contrib.auth.modelsimportUserimportdjango_monitorclassAuthor(models.Model):""" Moderated model """name=models.CharField(max_length=100)age=models.IntegerField()# To make sure that post_moderation signal is emitted.signal_emitted=models.BooleanField(editable=False,default=False)def__unicode__(self):returnself.namedefcollect_signal(self):"""Registers the emission of post_moderation signals"""self.signal_emitted=Trueself.save()django_monitor.nq(Author)defauth_moderation_handler(sender,instance,**kwargs):""" Receives the post_moderation signal from Author & passes it to the instance """instance.collect_signal()django_monitor.post_moderation.connect(auth_moderation_handler,sender=Author)classPublisher(models.Model):""" Not moderated model """name=models.CharField(max_length=255)num_awards=models.IntegerField()def__unicode__(self):returnself.nameclassWebPub(Publisher):""" To check something with subclassed models """passclassBook(models.Model):""" Moderated model with related objects """isbn=models.CharField(max_length=9)name=models.CharField(max_length=255)pages=models.IntegerField()authors=models.ManyToManyField(Author)publisher=models.ForeignKey(Publisher)def__unicode__(self):returnself.namedjango_monitor.nq(Book,['supplements',])classEBook(Book):""" Subclassing a moderated model """passdjango_monitor.nq(EBook,['supplements',])classSupplement(models.Model):""" Objects of this model get moderated along with Book"""serial_num=models.IntegerField()book=models.ForeignKey(Book,related_name='supplements')def__unicode__(self):return'Supplement %s to %s'%(self.serial_num,self.book)django_monitor.nq(Supplement)classReader(models.Model):""" To test an issue with custom querysets. See admin & tests """name=models.CharField(max_length=100)user=models.ForeignKey(User)django_monitor.nq(Reader)