Django Azure rest framework call 500 server error

I have an django app that is running fine locally, but deployed to azure app service I am getting a 500 error when when it requests data. The app is being deployed in a docker container on an azure app service:

URLs.py

 path('primaryexams/', TemplateView.as_view(template_name='xxxDB/primaryexams.html'), name='primaryExams'),
path('primaryexamsdata/', views.PrimaryExamsView.as_view(), name='primaryexam_data'),

views.py

class PrimaryExamsView(generics.ListAPIView):
    serializer_class = PrimaryExamSerializer
    template_name='xxxDB/primaryexams.html'

def get_queryset(self):
    return xxxPrimaryExamData.objects.all()

def filter_for_datatable(self, queryset):
    # filtering
    search_query = self.request.query_params.get('search[value]')
    if search_query:
        lookups = Q(xxxid__first_name__icontains=search_query)|Q(xxxid__last_name__icontains=search_query)|Q(xxxid__xx_id__icontains=search_query)
        queryset = xxxPrimaryExamData.objects.filter(lookups)
    
    return queryset

def list(self, request, *args, **kwargs):
    draw = request.query_params.get('draw')
    queryset = self.filter_queryset(self.get_queryset())
    recordsTotal = queryset.count()
    filtered_queryset = self.filter_for_datatable(queryset)

    try:
        start = int(request.query_params.get('start'))
    except (ValueError, TypeError):
        start = 0
    try:
        length = int(request.query_params.get('length'))
    except (ValueError, TypeError):
        length = 25
    end = length + start
    serializer = self.get_serializer(filtered_queryset[start:end], many=True)
    
    response = {
        'draw': draw,
        'recordsTotal': recordsTotal,
        'recordsFiltered': filtered_queryset.count(),
        'data': serializer.data,
    }
    return Response(response)    

serializers.py

class PrimaryExamSerializer(serializers.ModelSerializer):
    xxx_id = serializers.ReadOnlyField(source='xxxid.xxx_id')
    last_name = serializers.ReadOnlyField(source='xxxid.last_name')
    first_name = serializers.ReadOnlyField(source='xxxid.first_name')
    program_institution = serializers.ReadOnlyField(source='program_institution.institution_id')
    program_institution_name = serializers.ReadOnlyField(source='program_institution.institution_name')
    test_center_institution = serializers.ReadOnlyField(source='test_center_institution.institution_id', default='none')

class Meta:
    model = AbnsPrimaryExamData
    fields = (
        'id','xxx_id','last_name','first_name','medical_school','program_institution','program_institution_name','graduation_year','test_center_institution' 
    )

When I try to load the data I get an ajax error, and when I look at the request its getting a 500 server error:

https://xxxinternal.azurewebsites.net/xxxDB/primaryexamsdata/?draw=1&columns%5B0%5D%...blah...blahh

I have other views set up this same way that work just fine, but for what ever reason this view throws this error and displays no data. When I copy the url and paste it into my local version it displays the response just fine.

it turns out my problem was with gunicorn inside the docker. Running the docker locally also failed, but it gave me more information: Bad Request Request Line is too large (6060 > 4094)

setting --limit-request-line 8000 fixed the issue.

Back to Top