I’ve got a CMS that takes some dynamic content and renders it using a standard template. However I am now using template tags in the dynamic content itself so I have to do a render_to_string and then pass the results of that as a context variable to render_to_response. This seems wasteful.
What’s a better way to do this?
‘This seems wasteful’ Why does it seem that way?
Every template is a mix of tags and text. In your case some block of text has already been visited by a template engine. So what? Once it’s been transformed it’s just text and passes through the next template engine very, very quickly.
Do you have specific performance problems? Are you not meeting your transaction throughput requirements? Is there a specific problem?
Is the code too complex? Is it hard to maintain? Does it break all the time?
I think your solution is adequate. I’m not sure template tags in dynamic content is good from a debugging point of view, but from a basic ‘template rendering’ point of view, it is fine.