擅长:python、mysql、java
<p>用你的例子和你对布兰登回答的回答,这应该对你有用:</p>
<p>模板.html</p>
<pre><code>{% block content %}
Hey {{stuff}} {{stuff2}}!
{{ other_content }}
{% endblock content %}
</code></pre>
<p>视图.py</p>
<pre><code>from django.http import HttpResponse
from django.template import Context, loader
from django.template.loader import render_to_string
def somepage(request):
other_content = render_to_string("templates/template1.html", {"name":"John Doe"})
t = loader.get_template('templates/template.html')
c = Context({
'stuff': 'you',
'stuff2': 'the rocksteady crew',
'other_content': other_content,
})
return HttpResponse(t.render(c))
</code></pre>