def handleMatch(self, m):
        Model = apps.get_model(*self.MODEL)
        instance = None
        try:
            instance = Model.objects.get(pk=m.group(2))
        except Model.DoesNotExist:
            pass
        e = instance and self.create_element(instance)
        if e is None:
            e = markdown.util.etree.Element('p')
            e.set('class', 'text-muted')
            e.text = '[Invalid %s reference.]' % self.MODEL_NAME
        return e
dataset/ETHPy150Open 2buntu/2buntu-blog/twobuntu/cmarkdown/reference.py/ReferencePattern.handleMatch/original