Introduction
This is actually happen when the execution of a Django-based application is in process. This article has several connections with the previous articles. Those articles are the first one which has the title of ‘How to Print Page Display using HttpResponse Object in Django Application’ in this link. That link is an article which is collecting several important HttpResponse object usages. The first one is printing string format as in the article with the title of ‘How to Print Page Display using HttpResponse Object in Django Application’ in this link. The next one is an article with the title of ‘How to Solve Blank Page Display when Executing HttpResponse Object in Django Application’ in this link which is focusing on rendering the template to display the page.
In this article, it is facing an error when using HttpResponse. The error appear upon displaying a page or printing the content of a page. It is exist in a function with the name of ‘main’ which is available in the ‘views.py’ file :
def main(request): template = loader.get_template('templates/sysapp/main.html') return HttpResponse(template.render)
The following is the actual display of the output :
def main(request): template = loader.get_template('templates/sysapp/main.html') return HttpResponse(template.render)
Solution
Well, the solution for the above problem actually has already exist in the previous article. The problem still relates on the usage of HttpResponse object. The above HttpResponse object’s usage does not showing the expected output. In order to solve it, just change the last line of the above source code which is the following :
return HttpResponse(template.render)
Change the above line as follows :
return HttpResponse(template.render())
Finally, the output for rendering the page will appear as follows :
The solution itself, it is already exist in the previous article. It is an article with the title of ‘How to Solve Blank Page Display when Executing HttpResponse Object in Django Application’ in this link.