Repository: paperless-ngx/paperless-ngx

Issue:
[BUG] API returns 500 whenever a PATCH request without "created_date" is sent to the documents endpoint
### Description

The API doesn't accept any PATCH request made towards a documents endpoint (i.e. /api/documents/17/) if that patch request doesn't contain the new parameter "created_date".  The server responds with 500 (see logs below).

### Steps to reproduce

Go to the API endpoint of any document on a server running 1.8.0, like /api/documents/17/, select "raw data" and PATCH the following JSON to the server (or simply send a PATCH request with that JSON) :
```json
{
    "title": "Test"
}
```
This one will work:
```json
{
    "title": "Funny Image Test",
    "created_date": "2022-07-10"
}
```

### Webserver logs

```bash
[2022-08-13 09:12:31,317] [ERROR] [django.request] Internal Server Error: /api/documents/197/
Traceback (most recent call last):
  File "/usr/local/lib/python3.9/site-packages/asgiref/sync.py", line 472, in thread_handler
    raise exc_info[1]
  File "/usr/local/lib/python3.9/site-packages/django/core/handlers/exception.py", line 42, in inner
    response = await get_response(request)
  File "/usr/local/lib/python3.9/site-packages/django/core/handlers/base.py", line 253, in _get_response_async
    response = await wrapped_callback(
  File "/usr/local/lib/python3.9/site-packages/asgiref/sync.py", line 435, in __call__
    ret = await asyncio.wait_for(future, timeout=None)
  File "/usr/local/lib/python3.9/asyncio/tasks.py", line 442, in wait_for
    return await fut
  File "/usr/local/lib/python3.9/site-packages/asgiref/current_thread_executor.py", line 22, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/usr/local/lib/python3.9/site-packages/asgiref/sync.py", line 476, in thread_handler
    return func(*args, **kwargs)
  File "/usr/local/lib/python3.9/site-packages/django/views/decorators/csrf.py", line 54, in wrapped_view
    return view_func(*args, **kwargs)
  File "/usr/local/lib/python3.9/site-packages/rest_framework/viewsets.py", line 125, in view
    return self.dispatch(request, *args, **kwargs)
  File "/usr/local/lib/python3.9/site-packages/rest_framework/views.py", line 509, in dispatch
    response = self.handle_exception(exc)
  File "/usr/local/lib/python3.9/site-packages/rest_framework/views.py", line 469, in handle_exception
    self.raise_uncaught_exception(exc)
  File "/usr/local/lib/python3.9/site-packages/rest_framework/views.py", line 480, in raise_uncaught_exception
    raise exc
  File "/usr/local/lib/python3.9/site-packages/rest_framework/views.py", line 506, in dispatch
    response = handler(request, *args, **kwargs)
  File "/usr/local/lib/python3.9/site-packages/rest_framework/mixins.py", line 82, in partial_update
    return self.update(request, *args, **kwargs)
  File "/usr/src/paperless/src/documents/views.py", line 231, in update
    response = super().update(request, *args, **kwargs)
  File "/usr/local/lib/python3.9/site-packages/rest_framework/mixins.py", line 68, in update
    self.perform_update(serializer)
  File "/usr/local/lib/python3.9/site-packages/rest_framework/mixins.py", line 78, in perform_update
    serializer.save()
  File "/usr/local/lib/python3.9/site-packages/rest_framework/serializers.py", line 207, in save
    self.instance = self.update(self.instance, validated_data)
  File "/usr/src/paperless/src/documents/serialisers.py", line 243, in update
    validated_data.pop("created_date")
KeyError: 'created_date'
```


### Paperless-ngx version

1.8.0

### Host OS

Ubuntu 20.04 arm64 / Unraid 6.10.3 x86-64

### Installation method

Docker - official image

### Browser

_No response_

### Configuration changes

_No response_

### Other

_No response_


Discussion:
Ah, I did this, easy 1 line fix =)

Resolving patch:
diff --git a/src/documents/serialisers.py b/src/documents/serialisers.py
--- a/src/documents/serialisers.py
+++ b/src/documents/serialisers.py
@@ -240,7 +240,8 @@ def update(self, instance, validated_data):
             )
             instance.created = new_datetime
             instance.save()
-        validated_data.pop("created_date")
+        if "created_date" in validated_data:
+            validated_data.pop("created_date")
         super().update(instance, validated_data)
         return instance
 


Test patch: