How to resolve AssertionError: .accepted_renderer not set on Response in django and ajax

navnd

While I am calling Django url in ajax, getting below error

AssertionError: .accepted_renderer not set on Response.

This is my code:

function download(){

    $.ajax({
        url: "/mdm/exam_app/get_assessment_count/",
        dataType: 'json',
        data:{
        },
        type:'GET',
        success: function (data) {
          alert("inside the success method");
    },
        error: function(){
          console.log("error");
          }        
      });
}
Hybrid

If you're using a function based view, then this issue usually means you forgot to add the @api_view and the @renderer_classes decorator to your view.

Example:

from rest_framework.decorators import api_view, renderer_classes
from rest_framework.renderers import JSONRenderer, TemplateHTMLRenderer

@api_view(('GET',))
@renderer_classes((TemplateHTMLRenderer, JSONRenderer))
def get_assessment_count(request):
    [...]
    data = {'count': queryset.count()}
    return Response(data, template_name='assessments.html')

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Java

How to set response class in FastAPI?

From Dev

Django Ajax and Looping over Response

From Dev

How to set a header in an HTTP response?

From Dev

Django: set session via Ajax

From Dev

Set image content from ajax response

From Dev

AssertionError in django

From Dev

How to set far expires date on http response in django?

From Dev

AssertionError - no exception supplied - django

From Dev

How to alert ajax response

From Dev

How to get Ajax response in Go

From Dev

how to get $.ajax settings in response?

From Dev

Set Ajax response on jsp not working

From Dev

How to handle Ajax JSON response?

From Dev

Django - Slow Ajax response seems to be delayed

From Dev

How to read AJAX response variable?

From Dev

Set radio button checked with AJAX response

From Dev

How to resolve a set of promises and values using Bluebird

From Dev

Django template - ajax response - how to?

From Dev

JQuery $.ajax set cookie and get html response

From Dev

How to set resolve for babel-loader presets

From Dev

How to retrieve java Set and iterate over the values from response of ajax call?

From Dev

How to resolve java.lang.AssertionError when creating OkHttpClient in mockito?

From Dev

How to clear ajax response

From Dev

How to catch ajax error response?

From Dev

How to set AJAX response to jquery data table columns?

From Dev

Django 1.9.2 AssertionError: database connection isn't set to UTC

From Dev

C#: how to set DNS resolve timeout?

From Dev

How to set ajax response.responseText as global JS variable

From Dev

Not expected django query set response

Related Related

HotTag

Archive