We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
Internal Server Errors (e.g. on delete of user)
**Describe the bug**
Internal server error for some actions. I have set up a dockerless  installation and am able to access the application and the admin pages. However, some actions create errors.  For example: 

**To Reproduce**
Steps to reproduce the behavior:
1. Clicking delete user after providing admin password. Browser shows internal server error. Error in application is:

```
Internal Server Error: /settings/reports/2/delete
Traceback (most recent call last):
  File "/opt/bookwyrm/venv/lib/python3.10/site-packages/django/core/handlers/exception.py", line 47, in inner
    response = get_response(request)
  File "/opt/bookwyrm/venv/lib/python3.10/site-packages/django/core/handlers/base.py", line 204, in _get_response
    response = response.render()
  File "/opt/bookwyrm/venv/lib/python3.10/site-packages/django/template/response.py", line 105, in render
    self.content = self.rendered_content
  File "/opt/bookwyrm/venv/lib/python3.10/site-packages/django/template/response.py", line 81, in rendered_content
    template = self.resolve_template(self.template_name)
  File "/opt/bookwyrm/venv/lib/python3.10/site-packages/django/template/response.py", line 65, in resolve_template
    return get_template(template, using=self.using)
  File "/opt/bookwyrm/venv/lib/python3.10/site-packages/django/template/loader.py", line 19, in get_template
    raise TemplateDoesNotExist(template_name, chain=chain)
django.template.exceptions.TemplateDoesNotExist: user_admin/user.html
```



--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `bookwyrm/views/admin/reports.py`
Content:
```
1 """ moderation via flagged posts and users """
2 from django.contrib.auth.decorators import login_required, permission_required
3 from django.core.paginator import Paginator
4 from django.core.exceptions import PermissionDenied
5 from django.shortcuts import get_object_or_404, redirect
6 from django.template.response import TemplateResponse
7 from django.utils.decorators import method_decorator
8 from django.views import View
9 
10 from bookwyrm import forms, models
11 from bookwyrm.settings import PAGE_LENGTH
12 
13 
14 # pylint: disable=no-self-use
15 @method_decorator(login_required, name="dispatch")
16 @method_decorator(
17     permission_required("bookwyrm.moderate_user", raise_exception=True),
18     name="dispatch",
19 )
20 @method_decorator(
21     permission_required("bookwyrm.moderate_post", raise_exception=True),
22     name="dispatch",
23 )
24 class ReportsAdmin(View):
25     """list of reports"""
26 
27     def get(self, request):
28         """view current reports"""
29         filters = {}
30 
31         resolved = request.GET.get("resolved") == "true"
32         server = request.GET.get("server")
33         if server:
34             filters["user__federated_server__server_name"] = server
35         username = request.GET.get("username")
36         if username:
37             filters["user__username__icontains"] = username
38         filters["resolved"] = resolved
39 
40         reports = models.Report.objects.filter(**filters)
41         paginated = Paginator(reports, PAGE_LENGTH)
42         page = paginated.get_page(request.GET.get("page"))
43         data = {
44             "resolved": resolved,
45             "server": server,
46             "reports": page,
47             "page_range": paginated.get_elided_page_range(
48                 page.number, on_each_side=2, on_ends=1
49             ),
50         }
51         return TemplateResponse(request, "settings/reports/reports.html", data)
52 
53 
54 @method_decorator(login_required, name="dispatch")
55 @method_decorator(
56     permission_required("bookwyrm.moderate_user", raise_exception=True),
57     name="dispatch",
58 )
59 @method_decorator(
60     permission_required("bookwyrm.moderate_post", raise_exception=True),
61     name="dispatch",
62 )
63 class ReportAdmin(View):
64     """view a specific report"""
65 
66     def get(self, request, report_id):
67         """load a report"""
68         data = {
69             "report": get_object_or_404(models.Report, id=report_id),
70             "group_form": forms.UserGroupForm(),
71         }
72         return TemplateResponse(request, "settings/reports/report.html", data)
73 
74     def post(self, request, report_id):
75         """comment on a report"""
76         report = get_object_or_404(models.Report, id=report_id)
77         models.ReportComment.objects.create(
78             user=request.user,
79             report=report,
80             note=request.POST.get("note"),
81         )
82         return redirect("settings-report", report.id)
83 
84 
85 @login_required
86 @permission_required("bookwyrm.moderate_user")
87 def suspend_user(_, user_id):
88     """mark an account as inactive"""
89     user = get_object_or_404(models.User, id=user_id)
90     user.is_active = False
91     user.deactivation_reason = "moderator_suspension"
92     # this isn't a full deletion, so we don't want to tell the world
93     user.save(broadcast=False)
94     return redirect("settings-user", user.id)
95 
96 
97 @login_required
98 @permission_required("bookwyrm.moderate_user")
99 def unsuspend_user(_, user_id):
100     """mark an account as inactive"""
101     user = get_object_or_404(models.User, id=user_id)
102     user.is_active = True
103     user.deactivation_reason = None
104     # this isn't a full deletion, so we don't want to tell the world
105     user.save(broadcast=False)
106     return redirect("settings-user", user.id)
107 
108 
109 @login_required
110 @permission_required("bookwyrm.moderate_user")
111 def moderator_delete_user(request, user_id):
112     """permanently delete a user"""
113     user = get_object_or_404(models.User, id=user_id)
114 
115     # we can't delete users on other instances
116     if not user.local:
117         raise PermissionDenied()
118 
119     form = forms.DeleteUserForm(request.POST, instance=user)
120 
121     moderator = models.User.objects.get(id=request.user.id)
122     # check the moderator's password
123     if form.is_valid() and moderator.check_password(form.cleaned_data["password"]):
124         user.deactivation_reason = "moderator_deletion"
125         user.delete()
126         return redirect("settings-user", user.id)
127 
128     form.errors["password"] = ["Invalid password"]
129 
130     data = {"user": user, "group_form": forms.UserGroupForm(), "form": form}
131     return TemplateResponse(request, "user_admin/user.html", data)
132 
133 
134 @login_required
135 @permission_required("bookwyrm.moderate_post")
136 def resolve_report(_, report_id):
137     """mark a report as (un)resolved"""
138     report = get_object_or_404(models.Report, id=report_id)
139     report.resolved = not report.resolved
140     report.save()
141     if not report.resolved:
142         return redirect("settings-report", report.id)
143     return redirect("settings-reports")
144
```
--- 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/bookwyrm/views/admin/reports.py b/bookwyrm/views/admin/reports.py
--- a/bookwyrm/views/admin/reports.py
+++ b/bookwyrm/views/admin/reports.py
@@ -128,7 +128,7 @@
     form.errors["password"] = ["Invalid password"]
 
     data = {"user": user, "group_form": forms.UserGroupForm(), "form": form}
-    return TemplateResponse(request, "user_admin/user.html", data)
+    return TemplateResponse(request, "settings/users/user.html", data)
 
 
 @login_required

{"golden_diff": "diff --git a/bookwyrm/views/admin/reports.py b/bookwyrm/views/admin/reports.py\n--- a/bookwyrm/views/admin/reports.py\n+++ b/bookwyrm/views/admin/reports.py\n@@ -128,7 +128,7 @@\n     form.errors[\"password\"] = [\"Invalid password\"]\n \n     data = {\"user\": user, \"group_form\": forms.UserGroupForm(), \"form\": form}\n-    return TemplateResponse(request, \"user_admin/user.html\", data)\n+    return TemplateResponse(request, \"settings/users/user.html\", data)\n \n \n @login_required\n", "issue": "Internal Server Errors (e.g. on delete of user)\n**Describe the bug**\r\nInternal server error for some actions. I have set up a dockerless  installation and am able to access the application and the admin pages. However, some actions create errors.  For example: \r\n\r\n**To Reproduce**\r\nSteps to reproduce the behavior:\r\n1. Clicking delete user after providing admin password. Browser shows internal server error. Error in application is:\r\n\r\n```\r\nInternal Server Error: /settings/reports/2/delete\r\nTraceback (most recent call last):\r\n  File \"/opt/bookwyrm/venv/lib/python3.10/site-packages/django/core/handlers/exception.py\", line 47, in inner\r\n    response = get_response(request)\r\n  File \"/opt/bookwyrm/venv/lib/python3.10/site-packages/django/core/handlers/base.py\", line 204, in _get_response\r\n    response = response.render()\r\n  File \"/opt/bookwyrm/venv/lib/python3.10/site-packages/django/template/response.py\", line 105, in render\r\n    self.content = self.rendered_content\r\n  File \"/opt/bookwyrm/venv/lib/python3.10/site-packages/django/template/response.py\", line 81, in rendered_content\r\n    template = self.resolve_template(self.template_name)\r\n  File \"/opt/bookwyrm/venv/lib/python3.10/site-packages/django/template/response.py\", line 65, in resolve_template\r\n    return get_template(template, using=self.using)\r\n  File \"/opt/bookwyrm/venv/lib/python3.10/site-packages/django/template/loader.py\", line 19, in get_template\r\n    raise TemplateDoesNotExist(template_name, chain=chain)\r\ndjango.template.exceptions.TemplateDoesNotExist: user_admin/user.html\r\n```\r\n\r\n\n", "before_files": [{"content": "\"\"\" moderation via flagged posts and users \"\"\"\nfrom django.contrib.auth.decorators import login_required, permission_required\nfrom django.core.paginator import Paginator\nfrom django.core.exceptions import PermissionDenied\nfrom django.shortcuts import get_object_or_404, redirect\nfrom django.template.response import TemplateResponse\nfrom django.utils.decorators import method_decorator\nfrom django.views import View\n\nfrom bookwyrm import forms, models\nfrom bookwyrm.settings import PAGE_LENGTH\n\n\n# pylint: disable=no-self-use\n@method_decorator(login_required, name=\"dispatch\")\n@method_decorator(\n    permission_required(\"bookwyrm.moderate_user\", raise_exception=True),\n    name=\"dispatch\",\n)\n@method_decorator(\n    permission_required(\"bookwyrm.moderate_post\", raise_exception=True),\n    name=\"dispatch\",\n)\nclass ReportsAdmin(View):\n    \"\"\"list of reports\"\"\"\n\n    def get(self, request):\n        \"\"\"view current reports\"\"\"\n        filters = {}\n\n        resolved = request.GET.get(\"resolved\") == \"true\"\n        server = request.GET.get(\"server\")\n        if server:\n            filters[\"user__federated_server__server_name\"] = server\n        username = request.GET.get(\"username\")\n        if username:\n            filters[\"user__username__icontains\"] = username\n        filters[\"resolved\"] = resolved\n\n        reports = models.Report.objects.filter(**filters)\n        paginated = Paginator(reports, PAGE_LENGTH)\n        page = paginated.get_page(request.GET.get(\"page\"))\n        data = {\n            \"resolved\": resolved,\n            \"server\": server,\n            \"reports\": page,\n            \"page_range\": paginated.get_elided_page_range(\n                page.number, on_each_side=2, on_ends=1\n            ),\n        }\n        return TemplateResponse(request, \"settings/reports/reports.html\", data)\n\n\n@method_decorator(login_required, name=\"dispatch\")\n@method_decorator(\n    permission_required(\"bookwyrm.moderate_user\", raise_exception=True),\n    name=\"dispatch\",\n)\n@method_decorator(\n    permission_required(\"bookwyrm.moderate_post\", raise_exception=True),\n    name=\"dispatch\",\n)\nclass ReportAdmin(View):\n    \"\"\"view a specific report\"\"\"\n\n    def get(self, request, report_id):\n        \"\"\"load a report\"\"\"\n        data = {\n            \"report\": get_object_or_404(models.Report, id=report_id),\n            \"group_form\": forms.UserGroupForm(),\n        }\n        return TemplateResponse(request, \"settings/reports/report.html\", data)\n\n    def post(self, request, report_id):\n        \"\"\"comment on a report\"\"\"\n        report = get_object_or_404(models.Report, id=report_id)\n        models.ReportComment.objects.create(\n            user=request.user,\n            report=report,\n            note=request.POST.get(\"note\"),\n        )\n        return redirect(\"settings-report\", report.id)\n\n\n@login_required\n@permission_required(\"bookwyrm.moderate_user\")\ndef suspend_user(_, user_id):\n    \"\"\"mark an account as inactive\"\"\"\n    user = get_object_or_404(models.User, id=user_id)\n    user.is_active = False\n    user.deactivation_reason = \"moderator_suspension\"\n    # this isn't a full deletion, so we don't want to tell the world\n    user.save(broadcast=False)\n    return redirect(\"settings-user\", user.id)\n\n\n@login_required\n@permission_required(\"bookwyrm.moderate_user\")\ndef unsuspend_user(_, user_id):\n    \"\"\"mark an account as inactive\"\"\"\n    user = get_object_or_404(models.User, id=user_id)\n    user.is_active = True\n    user.deactivation_reason = None\n    # this isn't a full deletion, so we don't want to tell the world\n    user.save(broadcast=False)\n    return redirect(\"settings-user\", user.id)\n\n\n@login_required\n@permission_required(\"bookwyrm.moderate_user\")\ndef moderator_delete_user(request, user_id):\n    \"\"\"permanently delete a user\"\"\"\n    user = get_object_or_404(models.User, id=user_id)\n\n    # we can't delete users on other instances\n    if not user.local:\n        raise PermissionDenied()\n\n    form = forms.DeleteUserForm(request.POST, instance=user)\n\n    moderator = models.User.objects.get(id=request.user.id)\n    # check the moderator's password\n    if form.is_valid() and moderator.check_password(form.cleaned_data[\"password\"]):\n        user.deactivation_reason = \"moderator_deletion\"\n        user.delete()\n        return redirect(\"settings-user\", user.id)\n\n    form.errors[\"password\"] = [\"Invalid password\"]\n\n    data = {\"user\": user, \"group_form\": forms.UserGroupForm(), \"form\": form}\n    return TemplateResponse(request, \"user_admin/user.html\", data)\n\n\n@login_required\n@permission_required(\"bookwyrm.moderate_post\")\ndef resolve_report(_, report_id):\n    \"\"\"mark a report as (un)resolved\"\"\"\n    report = get_object_or_404(models.Report, id=report_id)\n    report.resolved = not report.resolved\n    report.save()\n    if not report.resolved:\n        return redirect(\"settings-report\", report.id)\n    return redirect(\"settings-reports\")\n", "path": "bookwyrm/views/admin/reports.py"}], "after_files": [{"content": "\"\"\" moderation via flagged posts and users \"\"\"\nfrom django.contrib.auth.decorators import login_required, permission_required\nfrom django.core.paginator import Paginator\nfrom django.core.exceptions import PermissionDenied\nfrom django.shortcuts import get_object_or_404, redirect\nfrom django.template.response import TemplateResponse\nfrom django.utils.decorators import method_decorator\nfrom django.views import View\n\nfrom bookwyrm import forms, models\nfrom bookwyrm.settings import PAGE_LENGTH\n\n\n# pylint: disable=no-self-use\n@method_decorator(login_required, name=\"dispatch\")\n@method_decorator(\n    permission_required(\"bookwyrm.moderate_user\", raise_exception=True),\n    name=\"dispatch\",\n)\n@method_decorator(\n    permission_required(\"bookwyrm.moderate_post\", raise_exception=True),\n    name=\"dispatch\",\n)\nclass ReportsAdmin(View):\n    \"\"\"list of reports\"\"\"\n\n    def get(self, request):\n        \"\"\"view current reports\"\"\"\n        filters = {}\n\n        resolved = request.GET.get(\"resolved\") == \"true\"\n        server = request.GET.get(\"server\")\n        if server:\n            filters[\"user__federated_server__server_name\"] = server\n        username = request.GET.get(\"username\")\n        if username:\n            filters[\"user__username__icontains\"] = username\n        filters[\"resolved\"] = resolved\n\n        reports = models.Report.objects.filter(**filters)\n        paginated = Paginator(reports, PAGE_LENGTH)\n        page = paginated.get_page(request.GET.get(\"page\"))\n        data = {\n            \"resolved\": resolved,\n            \"server\": server,\n            \"reports\": page,\n            \"page_range\": paginated.get_elided_page_range(\n                page.number, on_each_side=2, on_ends=1\n            ),\n        }\n        return TemplateResponse(request, \"settings/reports/reports.html\", data)\n\n\n@method_decorator(login_required, name=\"dispatch\")\n@method_decorator(\n    permission_required(\"bookwyrm.moderate_user\", raise_exception=True),\n    name=\"dispatch\",\n)\n@method_decorator(\n    permission_required(\"bookwyrm.moderate_post\", raise_exception=True),\n    name=\"dispatch\",\n)\nclass ReportAdmin(View):\n    \"\"\"view a specific report\"\"\"\n\n    def get(self, request, report_id):\n        \"\"\"load a report\"\"\"\n        data = {\n            \"report\": get_object_or_404(models.Report, id=report_id),\n            \"group_form\": forms.UserGroupForm(),\n        }\n        return TemplateResponse(request, \"settings/reports/report.html\", data)\n\n    def post(self, request, report_id):\n        \"\"\"comment on a report\"\"\"\n        report = get_object_or_404(models.Report, id=report_id)\n        models.ReportComment.objects.create(\n            user=request.user,\n            report=report,\n            note=request.POST.get(\"note\"),\n        )\n        return redirect(\"settings-report\", report.id)\n\n\n@login_required\n@permission_required(\"bookwyrm.moderate_user\")\ndef suspend_user(_, user_id):\n    \"\"\"mark an account as inactive\"\"\"\n    user = get_object_or_404(models.User, id=user_id)\n    user.is_active = False\n    user.deactivation_reason = \"moderator_suspension\"\n    # this isn't a full deletion, so we don't want to tell the world\n    user.save(broadcast=False)\n    return redirect(\"settings-user\", user.id)\n\n\n@login_required\n@permission_required(\"bookwyrm.moderate_user\")\ndef unsuspend_user(_, user_id):\n    \"\"\"mark an account as inactive\"\"\"\n    user = get_object_or_404(models.User, id=user_id)\n    user.is_active = True\n    user.deactivation_reason = None\n    # this isn't a full deletion, so we don't want to tell the world\n    user.save(broadcast=False)\n    return redirect(\"settings-user\", user.id)\n\n\n@login_required\n@permission_required(\"bookwyrm.moderate_user\")\ndef moderator_delete_user(request, user_id):\n    \"\"\"permanently delete a user\"\"\"\n    user = get_object_or_404(models.User, id=user_id)\n\n    # we can't delete users on other instances\n    if not user.local:\n        raise PermissionDenied()\n\n    form = forms.DeleteUserForm(request.POST, instance=user)\n\n    moderator = models.User.objects.get(id=request.user.id)\n    # check the moderator's password\n    if form.is_valid() and moderator.check_password(form.cleaned_data[\"password\"]):\n        user.deactivation_reason = \"moderator_deletion\"\n        user.delete()\n        return redirect(\"settings-user\", user.id)\n\n    form.errors[\"password\"] = [\"Invalid password\"]\n\n    data = {\"user\": user, \"group_form\": forms.UserGroupForm(), \"form\": form}\n    return TemplateResponse(request, \"settings/users/user.html\", data)\n\n\n@login_required\n@permission_required(\"bookwyrm.moderate_post\")\ndef resolve_report(_, report_id):\n    \"\"\"mark a report as (un)resolved\"\"\"\n    report = get_object_or_404(models.Report, id=report_id)\n    report.resolved = not report.resolved\n    report.save()\n    if not report.resolved:\n        return redirect(\"settings-report\", report.id)\n    return redirect(\"settings-reports\")\n", "path": "bookwyrm/views/admin/reports.py"}]}