pythondjangodjango-templatesdjango-errors

Attribute Error at / 'tuple' object has no attribute 'get' in Django


I add my index.html file to templates directory and then change all the src and etc but I receive this error what should I do for it:

D:\Django\2\blog_project\venv\Lib\site-packages\django\core\handlers\exception.py, line 55, in inner
                response = get_response(request)
                               ^^^^^^^^^^^^^^^^^^^^^ …
Local vars
D:\Django\2\blog_project\venv\Lib\site-packages\django\utils\deprecation.py, line 136, in __call__
            response = self.process_response(request, response)
                            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ …
Local vars
D:\Django\2\blog_project\venv\Lib\site-packages\django\middleware\clickjacking.py, line 27, in process_response
        if response.get("X-Frame-Options") is not None:
               ^^^^^^^^^^^^ …
Local vars

I try to run a html page in my django project but i receive an error


Solution

  • It appears that you return a tuple in your view, so likely something like:

    def my_view(request):
        #                                        trailing comma 🖟
        return render(request, 'name-of-some-template.html', {}),

    you should remove the trailing comma.