'collections.OrderedDict' object has no attribute 'status_code'

By Srinivas.k, 3 months ago
  • Bookmark
0

AttributeError at /create/

'collections.OrderedDict' object has no attribute 'status_code'

Request Method: GET

Request URL: http://127.0.0.1:8000/create/

Django Version: 3.1.2

Exception Type: AttributeError

Exception Value: 'collections.OrderedDict' object has no attribute 'status_code

Exception Location: C:\Users\Om\Anaconda3\envs\myenv\lib\site-packages\django\middleware\common.py, line 106, in process_response

Python Executable: C:\Users\Om\Anaconda3\envs\myenv\python.exe

Python Version: 3.6.12

Python Path: [']

Server time: Fri, 20 Aug 2021 09:22:34 +0000


Environment:



Request Method: GET

Request URL: http://127.0.0.1:8000/create/


Django Version: 3.1.2

Python Version: 3.6.12

Installed Applications:

['django.contrib.admin',

 'django.contrib.auth',

 'django.contrib.contenttypes',

 'django.contrib.sessions',

 'django.contrib.messages',

 'django.contrib.staticfiles',

 'salesforceapi']

Installed Middleware:

['django.middleware.security.SecurityMiddleware',

 'django.contrib.sessions.middleware.SessionMiddleware',

 'django.middleware.common.CommonMiddleware',

 'django.middleware.csrf.CsrfViewMiddleware',

 'django.contrib.auth.middleware.AuthenticationMiddleware',

 'django.contrib.messages.middleware.MessageMiddleware',

 'django.middleware.clickjacking.XFrameOptionsMiddleware']




Traceback (most recent call last):
 File "C:\Users\comp\Anaconda3\envs\myenv\lib\site-packages\django\core\handlers\exception.py", line 47, in inner
   response = get_response(request)
 File "C:\Users\comp\Anaconda3\envs\myenv\lib\site-packages\django\utils\deprecation.py", line 116, in __call__
   response = self.process_response(request, response)
 File "C:\Users\comp\Anaconda3\envs\myenv\lib\site-packages\django\middleware\common.py", line 106, in process_response
   if response.status_code == 404:

Exception Type: AttributeError at /create/
Exception Value: 'collections.OrderedDict' object has no attribute 'status_code'django

Rest api
Request
Response
Python
Django
1 Answer
1
Pritam Shinde

Your program does not return a valid response.

return response using JSON file

import JsonResponse

from django.http import JsonResponse 

return as follows

e.g.

return JsonResponse({
        'Data':response.json(),
        'status': response.status_code
        })

Your Answer

Webinars

More webinars

Related Discussions

Running random forest algorithm with one variable

View More