register_for_indexing('questions', Question) register_for_indexing( 'questions', TaggedItem, instance_to_indexee=( lambda i: (i.content_object if isinstance(i.content_object, Question) else None))) def _tag_added(sender, question_id, tag_name, **kwargs): """Signal handler for new tag on question.""" if tag_name == config.ESCALATE_TAG_NAME: escalate_question.delay(question_id) tag_added.connect(_tag_added, sender=Question, dispatch_uid='tagged_1337') class QuestionMetaData(ModelBase): """Metadata associated with a support question.""" question = models.ForeignKey('Question', related_name='metadata_set') name = models.SlugField(db_index=True) value = models.TextField() class Meta: unique_together = ('question', 'name') def __unicode__(self): return u'%s: %s' % (self.name, self.value[:50])