I'm trying display the outputs of 2 apps on a same web page, but am encountering issues when trying to use the solution proposed here.
I have a "main_app" handling the content of most of the page, and would like to add the output of a "sub_app" (i.e. a rendered <div>
element) on the same page.
Here's how I collect the output of sub_app
in a main_app
view:
from sub_app.views import sub_app_view #
def main_app_view(request):
my_sub_app_html = user_tests(request) #supposed to get rendered HTML content from sub_app
context = {
'sub_app_html ': my_sub_app_html,
}
return render(request, 'main_app.html', context)
Then the view in sub_app
:
def sub_app_view(request):
context = {
'sub_app_context': "foo",
}
return render(request, 'sub_app/sub_app.html', context)
main_app.html
contains:
<p>
{{ sub_app_html }}
</p>
and sub_app.html
:
<div id="mydiv">
{{ sub_app_context }}
</div>
But instead of correctly displaying the rendered HTML from sub_app_view
, what is shown in main_app.html
in the browser is:
<HttpResponse status_code=200, "text/html; charset=utf-8">
.
Is there a solution to this, or a better way to achieve linking between apps?