Skip to content Skip to sidebar Skip to footer

Django Returning Webpage Instead Of Json

I am fairly new to Django and am trying to implement a basic REST API in Django. I am having a news list in MySQL Database, and following various tutorials, successfully managed to

Solution 1:

Change DEFAULT_RENDERER_CLASSES in settings.py as

REST_FRAMEWORK = {
    'DEFAULT_RENDERER_CLASSES': (
        'rest_framework.renderers.JSONRenderer',
    )
}

It could be done view level by providing renderer_classes as,

from rest_framework import renderers


classMyView(...):
    renderer_classes = [renderers.JSONRenderer]

Post a Comment for "Django Returning Webpage Instead Of Json"