This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from tastypie import http | |
from tastypie.exceptions import ImmediateHttpResponse | |
from tastypie.resources import ModelResource | |
class CustomModelResource(ModelResource): | |
def deserialize(self, request, data, format='application/json'): | |
try: | |
return super(CustomModelResource, self).deserialize(request, data, format=format) | |
except Exception as e: | |
# if an exception occurred here it must be due to deserialization |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function sign(num) { | |
// IE does not support method sign here | |
if (typeof Math.sign === 'undefined') { | |
if (num > 0) { | |
return 1; | |
} | |
if (num < 0) { | |
return -1; | |
} | |
return 0; |