We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
RuntimeWarning: DateTimeField Log.client_timestamp received a naive datetime
## Description
When running `make test`, many warnings of this form are observed:
```
  /home/terraso/.local/lib/python3.11/site-packages/django/db/models/fields/__init__.py:1595: RuntimeWarning: DateTimeField Log.client_timestamp received a naive datetime (2023-07-11 22:39:48.700825) while time zone support is active.
    warnings.warn(
```

--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `terraso_backend/apps/audit_logs/services.py`
Content:
```
1 import typing
2 from datetime import datetime
3 from enum import Enum
4 
5 from django.contrib.contenttypes.models import ContentType
6 from django.core.paginator import Paginator
7 from django.db import transaction
8 from django.db.models.query import QuerySet
9 
10 from apps.core.models import User
11 
12 from . import api, models
13 
14 TEMPLATE = "{client_time} - {user} {action} {resource}"
15 
16 
17 class _AuditLogService:
18     """
19     AuditLogService implements the AuditLog protocol
20     """
21 
22     def log(
23         self,
24         user: User,
25         action: api.ACTIONS,
26         resource: object,
27         metadata: typing.Optional[dict[str, any]] = None,
28         client_time: typing.Optional[datetime] = None,
29     ) -> None:
30         """
31         log logs an action performed by a user on a resource
32         example:
33             log(user, "create", resource, client_time=1234567890)
34             :param client_time:
35             :param metadata:
36             :param action:
37             :param user:
38             :type resource: object
39 
40         """
41         if not hasattr(user, "id"):
42             raise ValueError("Invalid user")
43 
44         get_user_readable = getattr(user, "human_readable", None)
45         user_readable = get_user_readable() if callable(get_user_readable) else user.full_name()
46 
47         if not isinstance(action, Enum) or not hasattr(models.Events, action.value):
48             raise ValueError("Invalid action")
49 
50         resource_id = resource.id if hasattr(resource, "id") else None
51         if resource_id is None:
52             raise ValueError("Invalid resource")
53 
54         get_resource_human_readable = getattr(resource, "human_readable", None)
55         if callable(get_resource_human_readable):
56             resource_human_readable = get_resource_human_readable()
57         else:
58             resource_human_readable = resource_id
59 
60         content_type = ContentType.objects.get_for_model(resource)
61         resource_obj = resource
62 
63         resource_repr = resource.__dict__.__str__()
64 
65         if metadata is None:
66             metadata = {}
67 
68         with transaction.atomic():
69             log = models.Log(
70                 user=user,
71                 event=action.value,
72                 resource_id=resource_id,
73                 resource_content_type=content_type,
74                 resource_object=resource_obj,
75                 resource_json_repr=resource_repr,
76                 resource_human_readable=str(resource_human_readable),
77                 user_human_readable=str(user_readable),
78             )
79 
80             if client_time is None:
81                 client_time = datetime.now()
82             log.client_timestamp = client_time
83 
84             log.metadata = metadata
85             log.save()
86 
87 
88 class LogData:
89     """
90     LazyPaginator implements the Paginator protocol
91     """
92 
93     def __init__(self, data: QuerySet):
94         self.data = data
95 
96     def get_paginator(self, page_size: int = 10):
97         return Paginator(self.data, page_size)
98 
99     def __len__(self):
100         return len(self.data)
101 
102     def __iter__(self):
103         return iter(self.data)
104 
105 
106 def new_audit_logger() -> api.AuditLog:
107     """
108     new_audit_logger creates a new audit log
109     """
110     return _AuditLogService()
111
```
--- END FILES ---

Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.

Here is an example:

```diff
diff --git a/examples/server_async.py b/examples/server_async.py
--- a/examples/server_async.py
+++ b/examples/server_async.py
@@ -313,4 +313,4 @@
 
 
 if __name__ == "__main__":
-    asyncio.run(run_async_server("."), debug=True)
+    asyncio.run(run_async_server(), debug=True)
diff --git a/examples/server_sync.py b/examples/server_sync.py
--- a/examples/server_sync.py
+++ b/examples/server_sync.py
@@ -313,5 +313,5 @@
 
 
 if __name__ == "__main__":
-    server = run_sync_server(".")
+    server = run_sync_server()
     server.shutdown()

```

diff --git a/terraso_backend/apps/audit_logs/services.py b/terraso_backend/apps/audit_logs/services.py
--- a/terraso_backend/apps/audit_logs/services.py
+++ b/terraso_backend/apps/audit_logs/services.py
@@ -2,6 +2,7 @@
 from datetime import datetime
 from enum import Enum
 
+from django.conf import settings
 from django.contrib.contenttypes.models import ContentType
 from django.core.paginator import Paginator
 from django.db import transaction
@@ -79,7 +80,12 @@
 
             if client_time is None:
                 client_time = datetime.now()
-            log.client_timestamp = client_time
+            if settings.USE_TZ:
+                from django.utils.timezone import make_aware
+
+                log.client_timestamp = make_aware(client_time)
+            else:
+                log.client_timestamp = client_time
 
             log.metadata = metadata
             log.save()

{"golden_diff": "diff --git a/terraso_backend/apps/audit_logs/services.py b/terraso_backend/apps/audit_logs/services.py\n--- a/terraso_backend/apps/audit_logs/services.py\n+++ b/terraso_backend/apps/audit_logs/services.py\n@@ -2,6 +2,7 @@\n from datetime import datetime\n from enum import Enum\n \n+from django.conf import settings\n from django.contrib.contenttypes.models import ContentType\n from django.core.paginator import Paginator\n from django.db import transaction\n@@ -79,7 +80,12 @@\n \n             if client_time is None:\n                 client_time = datetime.now()\n-            log.client_timestamp = client_time\n+            if settings.USE_TZ:\n+                from django.utils.timezone import make_aware\n+\n+                log.client_timestamp = make_aware(client_time)\n+            else:\n+                log.client_timestamp = client_time\n \n             log.metadata = metadata\n             log.save()\n", "issue": "RuntimeWarning: DateTimeField Log.client_timestamp received a naive datetime\n## Description\r\nWhen running `make test`, many warnings of this form are observed:\r\n```\r\n  /home/terraso/.local/lib/python3.11/site-packages/django/db/models/fields/__init__.py:1595: RuntimeWarning: DateTimeField Log.client_timestamp received a naive datetime (2023-07-11 22:39:48.700825) while time zone support is active.\r\n    warnings.warn(\r\n```\n", "before_files": [{"content": "import typing\nfrom datetime import datetime\nfrom enum import Enum\n\nfrom django.contrib.contenttypes.models import ContentType\nfrom django.core.paginator import Paginator\nfrom django.db import transaction\nfrom django.db.models.query import QuerySet\n\nfrom apps.core.models import User\n\nfrom . import api, models\n\nTEMPLATE = \"{client_time} - {user} {action} {resource}\"\n\n\nclass _AuditLogService:\n    \"\"\"\n    AuditLogService implements the AuditLog protocol\n    \"\"\"\n\n    def log(\n        self,\n        user: User,\n        action: api.ACTIONS,\n        resource: object,\n        metadata: typing.Optional[dict[str, any]] = None,\n        client_time: typing.Optional[datetime] = None,\n    ) -> None:\n        \"\"\"\n        log logs an action performed by a user on a resource\n        example:\n            log(user, \"create\", resource, client_time=1234567890)\n            :param client_time:\n            :param metadata:\n            :param action:\n            :param user:\n            :type resource: object\n\n        \"\"\"\n        if not hasattr(user, \"id\"):\n            raise ValueError(\"Invalid user\")\n\n        get_user_readable = getattr(user, \"human_readable\", None)\n        user_readable = get_user_readable() if callable(get_user_readable) else user.full_name()\n\n        if not isinstance(action, Enum) or not hasattr(models.Events, action.value):\n            raise ValueError(\"Invalid action\")\n\n        resource_id = resource.id if hasattr(resource, \"id\") else None\n        if resource_id is None:\n            raise ValueError(\"Invalid resource\")\n\n        get_resource_human_readable = getattr(resource, \"human_readable\", None)\n        if callable(get_resource_human_readable):\n            resource_human_readable = get_resource_human_readable()\n        else:\n            resource_human_readable = resource_id\n\n        content_type = ContentType.objects.get_for_model(resource)\n        resource_obj = resource\n\n        resource_repr = resource.__dict__.__str__()\n\n        if metadata is None:\n            metadata = {}\n\n        with transaction.atomic():\n            log = models.Log(\n                user=user,\n                event=action.value,\n                resource_id=resource_id,\n                resource_content_type=content_type,\n                resource_object=resource_obj,\n                resource_json_repr=resource_repr,\n                resource_human_readable=str(resource_human_readable),\n                user_human_readable=str(user_readable),\n            )\n\n            if client_time is None:\n                client_time = datetime.now()\n            log.client_timestamp = client_time\n\n            log.metadata = metadata\n            log.save()\n\n\nclass LogData:\n    \"\"\"\n    LazyPaginator implements the Paginator protocol\n    \"\"\"\n\n    def __init__(self, data: QuerySet):\n        self.data = data\n\n    def get_paginator(self, page_size: int = 10):\n        return Paginator(self.data, page_size)\n\n    def __len__(self):\n        return len(self.data)\n\n    def __iter__(self):\n        return iter(self.data)\n\n\ndef new_audit_logger() -> api.AuditLog:\n    \"\"\"\n    new_audit_logger creates a new audit log\n    \"\"\"\n    return _AuditLogService()\n", "path": "terraso_backend/apps/audit_logs/services.py"}], "after_files": [{"content": "import typing\nfrom datetime import datetime\nfrom enum import Enum\n\nfrom django.conf import settings\nfrom django.contrib.contenttypes.models import ContentType\nfrom django.core.paginator import Paginator\nfrom django.db import transaction\nfrom django.db.models.query import QuerySet\n\nfrom apps.core.models import User\n\nfrom . import api, models\n\nTEMPLATE = \"{client_time} - {user} {action} {resource}\"\n\n\nclass _AuditLogService:\n    \"\"\"\n    AuditLogService implements the AuditLog protocol\n    \"\"\"\n\n    def log(\n        self,\n        user: User,\n        action: api.ACTIONS,\n        resource: object,\n        metadata: typing.Optional[dict[str, any]] = None,\n        client_time: typing.Optional[datetime] = None,\n    ) -> None:\n        \"\"\"\n        log logs an action performed by a user on a resource\n        example:\n            log(user, \"create\", resource, client_time=1234567890)\n            :param client_time:\n            :param metadata:\n            :param action:\n            :param user:\n            :type resource: object\n\n        \"\"\"\n        if not hasattr(user, \"id\"):\n            raise ValueError(\"Invalid user\")\n\n        get_user_readable = getattr(user, \"human_readable\", None)\n        user_readable = get_user_readable() if callable(get_user_readable) else user.full_name()\n\n        if not isinstance(action, Enum) or not hasattr(models.Events, action.value):\n            raise ValueError(\"Invalid action\")\n\n        resource_id = resource.id if hasattr(resource, \"id\") else None\n        if resource_id is None:\n            raise ValueError(\"Invalid resource\")\n\n        get_resource_human_readable = getattr(resource, \"human_readable\", None)\n        if callable(get_resource_human_readable):\n            resource_human_readable = get_resource_human_readable()\n        else:\n            resource_human_readable = resource_id\n\n        content_type = ContentType.objects.get_for_model(resource)\n        resource_obj = resource\n\n        resource_repr = resource.__dict__.__str__()\n\n        if metadata is None:\n            metadata = {}\n\n        with transaction.atomic():\n            log = models.Log(\n                user=user,\n                event=action.value,\n                resource_id=resource_id,\n                resource_content_type=content_type,\n                resource_object=resource_obj,\n                resource_json_repr=resource_repr,\n                resource_human_readable=str(resource_human_readable),\n                user_human_readable=str(user_readable),\n            )\n\n            if client_time is None:\n                client_time = datetime.now()\n            if settings.USE_TZ:\n                from django.utils.timezone import make_aware\n\n                log.client_timestamp = make_aware(client_time)\n            else:\n                log.client_timestamp = client_time\n\n            log.metadata = metadata\n            log.save()\n\n\nclass LogData:\n    \"\"\"\n    LazyPaginator implements the Paginator protocol\n    \"\"\"\n\n    def __init__(self, data: QuerySet):\n        self.data = data\n\n    def get_paginator(self, page_size: int = 10):\n        return Paginator(self.data, page_size)\n\n    def __len__(self):\n        return len(self.data)\n\n    def __iter__(self):\n        return iter(self.data)\n\n\ndef new_audit_logger() -> api.AuditLog:\n    \"\"\"\n    new_audit_logger creates a new audit log\n    \"\"\"\n    return _AuditLogService()\n", "path": "terraso_backend/apps/audit_logs/services.py"}]}