python - Django Tastypie add Content-Length header -


i quite new in django development. have resource , model:

model

class player(models.model):     pseudo = models.charfield(max_length=32, unique=true) 

modelresource

class playerresource(modelresource):     class meta:         queryset = player.objects.all()         resource_name = 'player'         authentication = basicauthentication()         authorization = authorization()         serializer = serializer(formats=['xml'])         filtering = {             'pseudo': all,         } 

and requesting players /api/v1/player/?format=xml seems response header : content-length missing causes issues in app. how can add in response header ?

thanks lot.

the lack of content-length due lack of middleware.
more information : here : how content length of django response object?

but can manually add content-length :

def create_response(self, request, data, response_class=httpresponse, **response_kwargs):         desired_format = self.determine_format(request)         serialized = self.serialize(request, data, desired_format)         response = response_class(content=serialized, content_type=build_content_type(desired_format), **response_kwargs)         response['content-length'] = len(response.content)         return response 

Comments

Popular posts from this blog

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -

node.js - Bad Request - node js ajax post -