Commit 573de11b by Ludwig Kraatz

changed buggy response + code ploishing

reponse didnt handle any headers at all. Accepts now a dict of headers
and sets those properly
parent cc55a7b6
......@@ -25,16 +25,11 @@ class CreateModelMixin(object):
return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST)
def get_success_headers(self,serializer):
headers = []
identity_field = identity_name = None
headers = {}
for name,field in serializer.fields.iteritems():
if isinstance(field,HyperlinkedIdentityField):
identity_name, identity_field = name, field
if identity_field:
#identity_field.initialize(serializer,"url")
headers.append(
("Location",identity_field.field_to_native(self.object,identity_name))
)
headers["Location"] = field.field_to_native(self.object,name)
break
return headers
def pre_save(self, obj):
......
......@@ -20,9 +20,12 @@ class Response(SimpleTemplateResponse):
"""
super(Response, self).__init__(None, status=status)
self.data = data
self.headers = headers and headers[:] or []
self.template_name = template_name
self.exception = exception
if headers:
for name,value in headers.iteritems():
self[name] = value
@property
def rendered_content(self):
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment