Django Render Template From Model Variables
I have a model: class DocumentoPaziente(models.Model): nome = models.CharField(null=True, blank=True, max_length=50) cognome = models.CharField(null=True, blank=True, max_l
Solution 1:
You can define a function in your model to do the rendering properly, like:
from django.template import Template, Context
classDocumentoPaziente(models.Model):
nome = models.CharField(null=True, blank=True, max_length=50)
cognome = models.CharField(null=True, blank=True, max_length=50)
contenuto = models.CharField(null=True, blank=True, max_length=100000)
defrender_content(self):
return Template(self.contuento).render(Context({'member': self}))
In your template, you can then render this with:
{% autoescape off %}
{{ member.render_content }}
{% endautoescape %}
Post a Comment for "Django Render Template From Model Variables"