Discussion:
'int' object has no attribute 'get'
aramis1212 via Django REST framework
2018-08-23 06:22:33 UTC
Permalink
any idea how to resolve this error message?

ia m running this htttpie : http GET
http://127.0.0.1:8000/picamaintenance/createapi/

My serializer looks like this:

class addpermissionSerializer(serializers.Serializer):

def generatepica(request):
cursor = connection.cursor()
cursor.callproc('AddPICA')
result_set = cursor.fetchall()
cursor.close()
sometext = result_set[0][0]
print(sometext)
return sometext

my view looks like this:

@csrf_exempt
def genpica(request):
"""
get a pica
"""
if request.method == 'GET':
serializer = addpermissionSerializer()
return (serializer.generatepica())

my url looks like this:
path('createapi/', views.genpica, name='permission_create_api'),

full error message looks like this:
2421
Internal Server Error: /picamaintenance/createapi/
Traceback (most recent call last):
File
"C:\Bitnami\djangostack-2.0.7-0\apps\django\django-2.0.7-py3.6.egg\django\core\handlers\exception.py",
line 35, in inner
response = get_response(request)
File
"C:\Bitnami\djangostack-2.0.7-0\apps\django\django-2.0.7-py3.6.egg\django\utils\deprecation.py",
line 97, in __call__
response = self.process_response(request, response)
File
"C:\Bitnami\djangostack-2.0.7-0\apps\django\django-2.0.7-py3.6.egg\django\middleware\clickjacking.py",
line 26, in process_response
if response.get('X-Frame-Options') is not None:
AttributeError: 'int' object has no attribute 'get'
[22/Aug/2018 22:20:32] "GET /picamaintenance/createapi/ HTTP/1.1" 500 59074

currently stuck on this one
--
You received this message because you are subscribed to the Google Groups "Django REST framework" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-rest-framework+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Oleg Nykolyn
2018-08-23 06:56:46 UTC
Permalink
Hi,

You should return `rest_framework.response.Response(serializer.generatepica())`
instead of `serializer.generatepica()`

---
Best regards,
Oleg

On Thu, Aug 23, 2018 at 9:22 AM aramis1212 via Django REST framework <
Post by aramis1212 via Django REST framework
any idea how to resolve this error message?
ia m running this htttpie : http GET
http://127.0.0.1:8000/picamaintenance/createapi/
cursor = connection.cursor()
cursor.callproc('AddPICA')
result_set = cursor.fetchall()
cursor.close()
sometext = result_set[0][0]
print(sometext)
return sometext
@csrf_exempt
"""
get a pica
"""
serializer = addpermissionSerializer()
return (serializer.generatepica())
path('createapi/', views.genpica, name='permission_create_api'),
2421
Internal Server Error: /picamaintenance/createapi/
File
"C:\Bitnami\djangostack-2.0.7-0\apps\django\django-2.0.7-py3.6.egg\django\core\handlers\exception.py",
line 35, in inner
response = get_response(request)
File
"C:\Bitnami\djangostack-2.0.7-0\apps\django\django-2.0.7-py3.6.egg\django\utils\deprecation.py",
line 97, in __call__
response = self.process_response(request, response)
File
"C:\Bitnami\djangostack-2.0.7-0\apps\django\django-2.0.7-py3.6.egg\django\middleware\clickjacking.py",
line 26, in process_response
AttributeError: 'int' object has no attribute 'get'
[22/Aug/2018 22:20:32] "GET /picamaintenance/createapi/ HTTP/1.1" 500 59074
currently stuck on this one
--
You received this message because you are subscribed to the Google Groups
"Django REST framework" group.
To unsubscribe from this group and stop receiving emails from it, send an
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google Groups "Django REST framework" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-rest-framework+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
aramis1212 via Django REST framework
2018-08-23 17:05:00 UTC
Permalink
Thank you, your response led me towards the correct answer. return
JsonResponse(serializer.generatepica(),safe=False).
unfortunately it didn't recognize Response(serializer.generatepica(). I
probably am missing the correct import.
Post by Oleg Nykolyn
Hi,
You should return `rest_framework.response.Response(serializer.generatepica())`
instead of `serializer.generatepica()`
---
Best regards,
Oleg
On Thu, Aug 23, 2018 at 9:22 AM aramis1212 via Django REST framework <
Post by aramis1212 via Django REST framework
any idea how to resolve this error message?
ia m running this htttpie : http GET
http://127.0.0.1:8000/picamaintenance/createapi/
cursor = connection.cursor()
cursor.callproc('AddPICA')
result_set = cursor.fetchall()
cursor.close()
sometext = result_set[0][0]
print(sometext)
return sometext
@csrf_exempt
"""
get a pica
"""
serializer = addpermissionSerializer()
return (serializer.generatepica())
path('createapi/', views.genpica, name='permission_create_api'),
2421
Internal Server Error: /picamaintenance/createapi/
File
"C:\Bitnami\djangostack-2.0.7-0\apps\django\django-2.0.7-py3.6.egg\django\core\handlers\exception.py",
line 35, in inner
response = get_response(request)
File
"C:\Bitnami\djangostack-2.0.7-0\apps\django\django-2.0.7-py3.6.egg\django\utils\deprecation.py",
line 97, in __call__
response = self.process_response(request, response)
File
"C:\Bitnami\djangostack-2.0.7-0\apps\django\django-2.0.7-py3.6.egg\django\middleware\clickjacking.py",
line 26, in process_response
AttributeError: 'int' object has no attribute 'get'
[22/Aug/2018 22:20:32] "GET /picamaintenance/createapi/ HTTP/1.1" 500 59074
currently stuck on this one
--
You received this message because you are subscribed to the Google Groups
"Django REST framework" group.
To unsubscribe from this group and stop receiving emails from it, send an
.
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google Groups "Django REST framework" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-rest-framework+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Continue reading on narkive:
Loading...