diff --git a/django_rest/test_app/templates/test_app/api_send.html b/django_rest/test_app/templates/test_app/api_send.html index 42ac53a08dc5d47d9e9ddf997bcd3885063a2e0d..f0e098e84936ab15eb9c2eb580e5cdfeaba345e8 100644 --- a/django_rest/test_app/templates/test_app/api_send.html +++ b/django_rest/test_app/templates/test_app/api_send.html @@ -215,7 +215,10 @@ value="Submit as PUT" title="Generally used to send data to the server, and update an existing resource by full replacement." > - <input type="submit" name="submit_put" value="Submit as PATCH" + <input + type="submit" + name="submit_patch" + value="Submit as PATCH" title="Generally used to send data to the server, and update an existing resource by partial replacement." > <input diff --git a/django_rest/test_app/views.py b/django_rest/test_app/views.py index bd5b04c893dcd7a6860cca35beb650a7c5d881ad..dc6cf51cf00ae9dd9f391f6040f76d77d4d76658 100644 --- a/django_rest/test_app/views.py +++ b/django_rest/test_app/views.py @@ -72,7 +72,7 @@ def view_with_group_check(request): # region API Views @csrf_exempt -@require_http_methods(["GET", "POST"]) +@require_http_methods(['GET', 'POST', 'PUT', 'PATCH', 'DELETE']) def api_parse(request): """Takes in JSON ping, and saves incoming value to web cookies. @@ -206,12 +206,6 @@ def api_send(request): response_error = {} sent_data = {} - # Get initial data. - form_initial = [{ - 'is_str': True, - 'value': 'This is a test entry.' - }] - # Initialize formset. form = ApiSendForm() @@ -380,6 +374,21 @@ def api_send(request): '404: Not Found - This error is often the result of the requested url not existing on the ' 'server. Are you sure you entered the destination URL correctly?' ) + elif response_success['status'] == 405: + # 405: Method Not Allowed + response_success['help_text'] = ( + '405: Method Not Allowed - This error is often the result of the destination understanding ' + 'the sent response type (GET/POST/PUT/PATCH/DELETE), but not supporting said type. ' + 'If this is a server you have access to, then double check that the endpoint is configured ' + 'correctly.' + ) + elif response_success['status'] == 415: + # 415: Unsupported Media Type + response_success['help_text'] = ( + '415: Unsupported Media Type - This error is often the result of the destination ' + 'being unable to parse the provided content. Are you sure the payload was entered ' + 'correctly?' + ) elif response_success['status'] == 500: # 500: Server Error response_success['help_text'] = ( diff --git a/django_v4/test_app/templates/test_app/api_send.html b/django_v4/test_app/templates/test_app/api_send.html index bf13d5f41b243992add5099bc2787a841c05d87e..48d1b13bed96007f8adc4087a8b970445393d15c 100644 --- a/django_v4/test_app/templates/test_app/api_send.html +++ b/django_v4/test_app/templates/test_app/api_send.html @@ -215,7 +215,10 @@ value="Submit as PUT" title="Generally used to send data to the server, and update an existing resource by full replacement." > - <input type="submit" name="submit_put" value="Submit as PATCH" + <input + type="submit" + name="submit_patch" + value="Submit as PATCH" title="Generally used to send data to the server, and update an existing resource by partial replacement." > <input diff --git a/django_v4/test_app/views.py b/django_v4/test_app/views.py index 3f021073867ef5765807481cd923d6c4a1fd730a..150b54a9dd61f6982c7eac6a13f46a9ef36296b5 100644 --- a/django_v4/test_app/views.py +++ b/django_v4/test_app/views.py @@ -65,7 +65,7 @@ def view_with_group_check(request): # region API Views @csrf_exempt -@require_http_methods(["GET", "POST"]) +@require_http_methods(['GET', 'POST', 'PUT', 'PATCH', 'DELETE']) def api_parse(request): """Takes in JSON ping, and saves incoming value to web cookies. @@ -199,12 +199,6 @@ def api_send(request): response_error = {} sent_data = {} - # Get initial data. - form_initial = [{ - 'is_str': True, - 'value': 'This is a test entry.' - }] - # Initialize formset. form = ApiSendForm() @@ -373,6 +367,21 @@ def api_send(request): '404: Not Found - This error is often the result of the requested url not existing on the ' 'server. Are you sure you entered the destination URL correctly?' ) + elif response_success['status'] == 405: + # 405: Method Not Allowed + response_success['help_text'] = ( + '405: Method Not Allowed - This error is often the result of the destination understanding ' + 'the sent response type (GET/POST/PUT/PATCH/DELETE), but not supporting said type. ' + 'If this is a server you have access to, then double check that the endpoint is configured ' + 'correctly.' + ) + elif response_success['status'] == 415: + # 415: Unsupported Media Type + response_success['help_text'] = ( + '415: Unsupported Media Type - This error is often the result of the destination ' + 'being unable to parse the provided content. Are you sure the payload was entered ' + 'correctly?' + ) elif response_success['status'] == 500: # 500: Server Error response_success['help_text'] = (