How to Solve Error NameError: name ‘get_wsgi_application’ is not defined on executing Django Application

Posted on

The article in this context, it is specifically discuss about how to solve error which is specified in the title of this article. The error itself is shown as follows :

NameError: name 'get_wsgi_application'

The error itself is generated or printed upon executing a python-based web application using a specific framework which in this context it is the Django framework. Basically, it is the continuation error that can be popped-up after solving the error message generated as shown in the article titled ‘How to Solve Error does not contain WSGI application ‘application’ on executing Django Application’ in this link.

After defining an application callable which is needed in order for a web-based application written in Python specifically Django framework in the file by adding the following line :

 application = get_wsgi_application()

It is obvious, since the error point out at the ‘get_wsgi_application’ where it is considered as the error because of the name literally. But soon after that, executing the web-based application powered by Django framework ends in generating another different error. The error itself is shown above. So, having this kind of error actually prevent from executing the web-based application properly. The solution is actually quite easy. It is done by adding the following line in the script :

from django.core.wsgi import get_wsgi_application

The line added is actually the important thing to solve the problem or error generated specifically in order for the method or function defined as ‘get_wsgi_application()’ to be assigned to a variable named ‘application’. It is actually derived by impoting ‘get_wgsi_application’ as shown in the previous line.

After adding the line, just try to re-execute the page which is actually based on Django framework written in Python. If there is no other specific thing or any other line which is becoming the main source that can trigger further error, the actual problem is already solved with the error generated will be disappeared.

Leave a Reply