'Either updates an existing resource or creates a new one with the
provided data.
Calls ``obj_update`` with the provided data first, but falls back to
``obj_create`` if the object does not already exist.
If a new resource is created, return ``HttpCreated`` (201 Created).
If ``Meta.always_return_data = True``, there will be a populated body
of serialized data.
If an existing resource is modified and
``Meta.always_return_data = False`` (default), return ``HttpNoContent``
(204 No Content).
If an existing resource is modified and
``Meta.always_return_data = True``, return ``HttpAccepted`` (200
OK).'

def put_detail(self, request, **kwargs):

    deserialized = self.deserialize(request, request.body, format=request.META.get(u'CONTENT_TYPE', u'application/json'))
    deserialized = self.alter_deserialized_detail_data(request, deserialized)
    bundle = self.build_bundle(data=dict_strip_unicode_keys(deserialized), request=request)
    try:
        updated_bundle = self.obj_update(bundle=bundle, **self.remove_api_resource_names(kwargs))
        if (not self._meta.always_return_data):
            return http.HttpNoContent()
        else:
            updated_bundle.obj._prefetched_objects_cache = {}
            updated_bundle = self.full_dehydrate(updated_bundle)
            updated_bundle = self.alter_detail_data_to_serialize(request, updated_bundle)
            return self.create_response(request, updated_bundle)
    except (NotFound, MultipleObjectsReturned):
        updated_bundle = self.obj_create(bundle=bundle, **self.remove_api_resource_names(kwargs))
        location = self.get_resource_uri(updated_bundle)
        if (not self._meta.always_return_data):
            return http.HttpCreated(location=location)
        else:
            updated_bundle = self.full_dehydrate(updated_bundle)
            updated_bundle = self.alter_detail_data_to_serialize(request, updated_bundle)
            return self.create_response(request, updated_bundle, response_class=http.HttpCreated, location=location)
