mardi 5 mai 2015

Is it possible to process arbitrary content with the Django template processor?

My web app contains a banner serving API.

Abridged banner model:

class Banner(models.Model):
    name = models.CharField(max_length=50)
    ad_tag = models.TextField()
    active = models.BooleanField(default=True)
    priority = models.IntegerField(null=True, blank=False)

    def __unicode__(self):
        return self.name

The banner serving API accepts some GET parameters and, based on these parameters, returns a Django template that spits out the ad_tag TextField above. The ad_tag field is the banner's HTML:

<!-- ... -->
<body>
    {{ ad_tag|safe}}
</body>

My problem: I would like to process the contents of the ad_tag field with the Django template processor, so I can use includes, template logic, etc. Is this possible?

Aucun commentaire:

Enregistrer un commentaire