def dispatch(self, request, *args, **kwargs):
allowed_methods = self.get_allowed_methods()<EOL>try:<EOL><INDENT>if request.method == '<STR_LIT:GET>' and '<STR_LIT:GET>' in allowed_methods:<EOL><INDENT>if '<STR_LIT>' in request.GET or self.slug_field in request.GET:<EOL><INDENT>return self.ng_get(request, *args, **kwargs)<EOL><DEDENT>return self.ng_query(request, *args, **kwargs)<EOL><DEDENT>elif request.method == '<STR_LIT:POST>' and '<STR_LIT:POST>' in allowed_methods:<EOL><INDENT>return self.ng_save(request, *args, **kwargs)<EOL><DEDENT>elif request.method == '<STR_LIT>' and '<STR_LIT>' in allowed_methods:<EOL><INDENT>return self.ng_delete(request, *args, **kwargs)<EOL><DEDENT><DEDENT>except self.model.DoesNotExist as e:<EOL><INDENT>return self.error_json_response(e.args[<NUM_LIT:0>], <NUM_LIT>)<EOL><DEDENT>except NgMissingParameterError as e:<EOL><INDENT>return self.error_json_response(e.args[<NUM_LIT:0>])<EOL><DEDENT>except JSONResponseException as e:<EOL><INDENT>return self.error_json_response(e.args[<NUM_LIT:0>], e.status_code)<EOL><DEDENT>except ValidationError as e:<EOL><INDENT>if hasattr(e, '<STR_LIT>'):<EOL><INDENT>return self.error_json_response('<STR_LIT>', detail=e.message_dict)<EOL><DEDENT>else:<EOL><INDENT>return self.error_json_response(e.message)<EOL><DEDENT><DEDENT>return self.error_json_response('<STR_LIT>'.format(request.method), <NUM_LIT>)<EOL>
Override dispatch to call appropriate methods:
* $query - ng_query
* $get - ng_get
* $save - ng_save
* $delete and $remove - ng_delete