python - Django render_to_string <body><head> tag -


i'm django app load static html page main template. static html page email template. goal edit email in main template. email html page don't have view in url.py. don't use include in main template , don't want use iframe. problem load html email tag (like

 <html>  <head>  <body> 

) when page's render tag deleted (or don't see them in main template...). code:

view.py

def my_view(request):     file_name = "/templates/path/emailtemplate.html" htmlblock = render_to_string(file_name, {}) return render_to_response('main_template.html', {         'htmlblock': htmlblock,     },     context_instance = requestcontext(request)) 

main_template.html

    <html>  <head>   ....   <head>     <body>       <div id="content">         {{htmlblock}}       </div>     </body> </html> 

this have:

<html>  <head>   ....   <head>     <body>       <div id="content">         <html>         <head>           ....         </head>              <body>               ...             </body>         </html>       </div>     </body> </html> 

is possible without iframe? lot help.

edit

my goal have

 <html>  <head>  <body>  

tag

 <div id="content">  

where load email template.

my goal edit email in main template.

you can read template string by

with open('/templates/path/emailtemplate.html', 'r') content_file:     content = content_file.read() 

you can use same value edit field , visible usual. can used as.

return render_to_response('main_template.html', {         'htmlblock': content,     }, context_instance = requestcontext(request)) 

you can further use same in edit field as:

<textarea value={{htmlblock}}> 

or render same in

<div id="content">{{htmlblock}}</div> 

Comments