We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
[Bug report] Error on Django Admin search
How to reproduce the behaviour
---------
![image](https://user-images.githubusercontent.com/1063219/86004768-6edc3f80-ba1c-11ea-8a58-349a57de6fce.png)

Press "Search".

```
backend_1   | Internal Server Error: /admin/api/document/
backend_1   | Traceback (most recent call last):
backend_1   |   File "/src/venv/lib/python3.6/site-packages/django/core/handlers/exception.py", line 34, in inner
backend_1   |     response = get_response(request)
backend_1   |   File "/src/venv/lib/python3.6/site-packages/django/core/handlers/base.py", line 115, in _get_response
backend_1   |     response = self.process_exception_by_middleware(e, request)
backend_1   |   File "/src/venv/lib/python3.6/site-packages/django/core/handlers/base.py", line 113, in _get_response
backend_1   |     response = wrapped_callback(request, *callback_args, **callback_kwargs)
backend_1   |   File "/src/venv/lib/python3.6/site-packages/django/contrib/admin/options.py", line 606, in wrapper
backend_1   |     return self.admin_site.admin_view(view)(*args, **kwargs)
backend_1   |   File "/src/venv/lib/python3.6/site-packages/django/utils/decorators.py", line 142, in _wrapped_view
backend_1   |     response = view_func(request, *args, **kwargs)
backend_1   |   File "/src/venv/lib/python3.6/site-packages/django/views/decorators/cache.py", line 44, in _wrapped_view_func
backend_1   |     response = view_func(request, *args, **kwargs)
backend_1   |   File "/src/venv/lib/python3.6/site-packages/django/contrib/admin/sites.py", line 223, in inner
backend_1   |     return view(request, *args, **kwargs)
backend_1   |   File "/src/venv/lib/python3.6/site-packages/django/utils/decorators.py", line 45, in _wrapper
backend_1   |     return bound_method(*args, **kwargs)
backend_1   |   File "/src/venv/lib/python3.6/site-packages/django/utils/decorators.py", line 142, in _wrapped_view
backend_1   |     response = view_func(request, *args, **kwargs)
backend_1   |   File "/src/venv/lib/python3.6/site-packages/django/contrib/admin/options.py", line 1685, in changelist_view
backend_1   |     cl = self.get_changelist_instance(request)
backend_1   |   File "/src/venv/lib/python3.6/site-packages/django/contrib/admin/options.py", line 744, in get_changelist_instance
backend_1   |     sortable_by,
backend_1   |   File "/src/venv/lib/python3.6/site-packages/django/contrib/admin/views/main.py", line 81, in __init__
backend_1   |     self.queryset = self.get_queryset(request)
backend_1   |   File "/src/venv/lib/python3.6/site-packages/django/contrib/admin/views/main.py", line 439, in get_queryset
backend_1   |     qs, search_use_distinct = self.model_admin.get_search_results(request, qs, self.query)
backend_1   |   File "/src/venv/lib/python3.6/site-packages/django/contrib/admin/options.py", line 1023, in get_search_results
backend_1   |     queryset = queryset.filter(reduce(operator.or_, or_queries))
backend_1   |   File "/src/venv/lib/python3.6/site-packages/django/db/models/query.py", line 892, in filter
backend_1   |     return self._filter_or_exclude(False, *args, **kwargs)
backend_1   |   File "/src/venv/lib/python3.6/site-packages/django/db/models/query.py", line 910, in _filter_or_exclude
backend_1   |     clone.query.add_q(Q(*args, **kwargs))
backend_1   |   File "/src/venv/lib/python3.6/site-packages/django/db/models/sql/query.py", line 1290, in add_q
backend_1   |     clause, _ = self._add_q(q_object, self.used_aliases)
backend_1   |   File "/src/venv/lib/python3.6/site-packages/django/db/models/sql/query.py", line 1312, in _add_q
backend_1   |     current_negated, allow_joins, split_subq, simple_col)
backend_1   |   File "/src/venv/lib/python3.6/site-packages/django/db/models/sql/query.py", line 1318, in _add_q
backend_1   |     split_subq=split_subq, simple_col=simple_col,
backend_1   |   File "/src/venv/lib/python3.6/site-packages/django/db/models/sql/query.py", line 1251, in build_filter
backend_1   |     condition = self.build_lookup(lookups, col, value)
backend_1   |   File "/src/venv/lib/python3.6/site-packages/django/db/models/sql/query.py", line 1107, in build_lookup
backend_1   |     raise FieldError('Related Field got invalid lookup: {}'.format(lookup_name))
backend_1   | django.core.exceptions.FieldError: Related Field got invalid lookup: icontains
backend_1   | [29/Jun/2020 12:25:49] "GET /admin/api/document/?q=request HTTP/1.1" 500 160618
```

Is this like https://stackoverflow.com/questions/11754877/troubleshooting-related-field-has-invalid-lookup-icontains?

Your Environment
---------
<!-- Include details of your environment.-->
*   Operating System: Calculate Linux 20.6
*   Python Version Used: system Python version is 3.7.7
*   When you install doccano: 4927a01f090b91d8e14e467f2fd40d8301612e72
*   How did you install doccano (Heroku button etc): Docker Compose


--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `app/api/admin.py`
Content:
```
1 from django.contrib import admin
2 
3 from .models import Label, Document, Project
4 from .models import Role, RoleMapping
5 from .models import DocumentAnnotation, SequenceAnnotation, Seq2seqAnnotation
6 from .models import TextClassificationProject, SequenceLabelingProject, Seq2seqProject
7 
8 
9 class LabelAdmin(admin.ModelAdmin):
10     list_display = ('text', 'project', 'text_color', 'background_color')
11     ordering = ('project',)
12     search_fields = ('project',)
13 
14 
15 class DocumentAdmin(admin.ModelAdmin):
16     list_display = ('text', 'project', 'meta')
17     ordering = ('project',)
18     search_fields = ('project',)
19 
20 
21 class ProjectAdmin(admin.ModelAdmin):
22     list_display = ('name', 'description', 'project_type', 'randomize_document_order', 'collaborative_annotation')
23     ordering = ('project_type',)
24     search_fields = ('name',)
25 
26 
27 class SequenceAnnotationAdmin(admin.ModelAdmin):
28     list_display = ('document', 'label', 'start_offset', 'user')
29     ordering = ('document',)
30     search_fields = ('document',)
31 
32 
33 class DocumentAnnotationAdmin(admin.ModelAdmin):
34     list_display = ('document', 'label', 'user')
35     ordering = ('document',)
36     search_fields = ('document',)
37 
38 
39 class Seq2seqAnnotationAdmin(admin.ModelAdmin):
40     list_display = ('document', 'text', 'user')
41     ordering = ('document',)
42     search_fields = ('document',)
43 
44 
45 class RoleAdmin(admin.ModelAdmin):
46     list_display = ('name', 'description')
47     ordering = ('name',)
48     search_fields = ('name',)
49 
50 
51 class RoleMappingAdmin(admin.ModelAdmin):
52     list_display = ('user', 'role', 'project', )
53     ordering = ('user',)
54     search_fields = ('user',)
55 
56 
57 admin.site.register(DocumentAnnotation, DocumentAnnotationAdmin)
58 admin.site.register(SequenceAnnotation, SequenceAnnotationAdmin)
59 admin.site.register(Seq2seqAnnotation, Seq2seqAnnotationAdmin)
60 admin.site.register(Label, LabelAdmin)
61 admin.site.register(Document, DocumentAdmin)
62 admin.site.register(Project, ProjectAdmin)
63 admin.site.register(TextClassificationProject, ProjectAdmin)
64 admin.site.register(SequenceLabelingProject, ProjectAdmin)
65 admin.site.register(Seq2seqProject, ProjectAdmin)
66 admin.site.register(Role, RoleAdmin)
67 admin.site.register(RoleMapping, RoleMappingAdmin)
68
```
--- 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/app/api/admin.py b/app/api/admin.py
--- a/app/api/admin.py
+++ b/app/api/admin.py
@@ -9,13 +9,13 @@
 class LabelAdmin(admin.ModelAdmin):
     list_display = ('text', 'project', 'text_color', 'background_color')
     ordering = ('project',)
-    search_fields = ('project',)
+    search_fields = ('text',)
 
 
 class DocumentAdmin(admin.ModelAdmin):
     list_display = ('text', 'project', 'meta')
     ordering = ('project',)
-    search_fields = ('project',)
+    search_fields = ('text',)
 
 
 class ProjectAdmin(admin.ModelAdmin):
@@ -27,19 +27,19 @@
 class SequenceAnnotationAdmin(admin.ModelAdmin):
     list_display = ('document', 'label', 'start_offset', 'user')
     ordering = ('document',)
-    search_fields = ('document',)
+    search_fields = ('document__text',)
 
 
 class DocumentAnnotationAdmin(admin.ModelAdmin):
     list_display = ('document', 'label', 'user')
     ordering = ('document',)
-    search_fields = ('document',)
+    search_fields = ('document__text',)
 
 
 class Seq2seqAnnotationAdmin(admin.ModelAdmin):
     list_display = ('document', 'text', 'user')
     ordering = ('document',)
-    search_fields = ('document',)
+    search_fields = ('document__text',)
 
 
 class RoleAdmin(admin.ModelAdmin):
@@ -51,7 +51,7 @@
 class RoleMappingAdmin(admin.ModelAdmin):
     list_display = ('user', 'role', 'project', )
     ordering = ('user',)
-    search_fields = ('user',)
+    search_fields = ('user__username',)
 
 
 admin.site.register(DocumentAnnotation, DocumentAnnotationAdmin)

{"golden_diff": "diff --git a/app/api/admin.py b/app/api/admin.py\n--- a/app/api/admin.py\n+++ b/app/api/admin.py\n@@ -9,13 +9,13 @@\n class LabelAdmin(admin.ModelAdmin):\n     list_display = ('text', 'project', 'text_color', 'background_color')\n     ordering = ('project',)\n-    search_fields = ('project',)\n+    search_fields = ('text',)\n \n \n class DocumentAdmin(admin.ModelAdmin):\n     list_display = ('text', 'project', 'meta')\n     ordering = ('project',)\n-    search_fields = ('project',)\n+    search_fields = ('text',)\n \n \n class ProjectAdmin(admin.ModelAdmin):\n@@ -27,19 +27,19 @@\n class SequenceAnnotationAdmin(admin.ModelAdmin):\n     list_display = ('document', 'label', 'start_offset', 'user')\n     ordering = ('document',)\n-    search_fields = ('document',)\n+    search_fields = ('document__text',)\n \n \n class DocumentAnnotationAdmin(admin.ModelAdmin):\n     list_display = ('document', 'label', 'user')\n     ordering = ('document',)\n-    search_fields = ('document',)\n+    search_fields = ('document__text',)\n \n \n class Seq2seqAnnotationAdmin(admin.ModelAdmin):\n     list_display = ('document', 'text', 'user')\n     ordering = ('document',)\n-    search_fields = ('document',)\n+    search_fields = ('document__text',)\n \n \n class RoleAdmin(admin.ModelAdmin):\n@@ -51,7 +51,7 @@\n class RoleMappingAdmin(admin.ModelAdmin):\n     list_display = ('user', 'role', 'project', )\n     ordering = ('user',)\n-    search_fields = ('user',)\n+    search_fields = ('user__username',)\n \n \n admin.site.register(DocumentAnnotation, DocumentAnnotationAdmin)\n", "issue": "[Bug report] Error on Django Admin search\nHow to reproduce the behaviour\r\n---------\r\n![image](https://user-images.githubusercontent.com/1063219/86004768-6edc3f80-ba1c-11ea-8a58-349a57de6fce.png)\r\n\r\nPress \"Search\".\r\n\r\n```\r\nbackend_1   | Internal Server Error: /admin/api/document/\r\nbackend_1   | Traceback (most recent call last):\r\nbackend_1   |   File \"/src/venv/lib/python3.6/site-packages/django/core/handlers/exception.py\", line 34, in inner\r\nbackend_1   |     response = get_response(request)\r\nbackend_1   |   File \"/src/venv/lib/python3.6/site-packages/django/core/handlers/base.py\", line 115, in _get_response\r\nbackend_1   |     response = self.process_exception_by_middleware(e, request)\r\nbackend_1   |   File \"/src/venv/lib/python3.6/site-packages/django/core/handlers/base.py\", line 113, in _get_response\r\nbackend_1   |     response = wrapped_callback(request, *callback_args, **callback_kwargs)\r\nbackend_1   |   File \"/src/venv/lib/python3.6/site-packages/django/contrib/admin/options.py\", line 606, in wrapper\r\nbackend_1   |     return self.admin_site.admin_view(view)(*args, **kwargs)\r\nbackend_1   |   File \"/src/venv/lib/python3.6/site-packages/django/utils/decorators.py\", line 142, in _wrapped_view\r\nbackend_1   |     response = view_func(request, *args, **kwargs)\r\nbackend_1   |   File \"/src/venv/lib/python3.6/site-packages/django/views/decorators/cache.py\", line 44, in _wrapped_view_func\r\nbackend_1   |     response = view_func(request, *args, **kwargs)\r\nbackend_1   |   File \"/src/venv/lib/python3.6/site-packages/django/contrib/admin/sites.py\", line 223, in inner\r\nbackend_1   |     return view(request, *args, **kwargs)\r\nbackend_1   |   File \"/src/venv/lib/python3.6/site-packages/django/utils/decorators.py\", line 45, in _wrapper\r\nbackend_1   |     return bound_method(*args, **kwargs)\r\nbackend_1   |   File \"/src/venv/lib/python3.6/site-packages/django/utils/decorators.py\", line 142, in _wrapped_view\r\nbackend_1   |     response = view_func(request, *args, **kwargs)\r\nbackend_1   |   File \"/src/venv/lib/python3.6/site-packages/django/contrib/admin/options.py\", line 1685, in changelist_view\r\nbackend_1   |     cl = self.get_changelist_instance(request)\r\nbackend_1   |   File \"/src/venv/lib/python3.6/site-packages/django/contrib/admin/options.py\", line 744, in get_changelist_instance\r\nbackend_1   |     sortable_by,\r\nbackend_1   |   File \"/src/venv/lib/python3.6/site-packages/django/contrib/admin/views/main.py\", line 81, in __init__\r\nbackend_1   |     self.queryset = self.get_queryset(request)\r\nbackend_1   |   File \"/src/venv/lib/python3.6/site-packages/django/contrib/admin/views/main.py\", line 439, in get_queryset\r\nbackend_1   |     qs, search_use_distinct = self.model_admin.get_search_results(request, qs, self.query)\r\nbackend_1   |   File \"/src/venv/lib/python3.6/site-packages/django/contrib/admin/options.py\", line 1023, in get_search_results\r\nbackend_1   |     queryset = queryset.filter(reduce(operator.or_, or_queries))\r\nbackend_1   |   File \"/src/venv/lib/python3.6/site-packages/django/db/models/query.py\", line 892, in filter\r\nbackend_1   |     return self._filter_or_exclude(False, *args, **kwargs)\r\nbackend_1   |   File \"/src/venv/lib/python3.6/site-packages/django/db/models/query.py\", line 910, in _filter_or_exclude\r\nbackend_1   |     clone.query.add_q(Q(*args, **kwargs))\r\nbackend_1   |   File \"/src/venv/lib/python3.6/site-packages/django/db/models/sql/query.py\", line 1290, in add_q\r\nbackend_1   |     clause, _ = self._add_q(q_object, self.used_aliases)\r\nbackend_1   |   File \"/src/venv/lib/python3.6/site-packages/django/db/models/sql/query.py\", line 1312, in _add_q\r\nbackend_1   |     current_negated, allow_joins, split_subq, simple_col)\r\nbackend_1   |   File \"/src/venv/lib/python3.6/site-packages/django/db/models/sql/query.py\", line 1318, in _add_q\r\nbackend_1   |     split_subq=split_subq, simple_col=simple_col,\r\nbackend_1   |   File \"/src/venv/lib/python3.6/site-packages/django/db/models/sql/query.py\", line 1251, in build_filter\r\nbackend_1   |     condition = self.build_lookup(lookups, col, value)\r\nbackend_1   |   File \"/src/venv/lib/python3.6/site-packages/django/db/models/sql/query.py\", line 1107, in build_lookup\r\nbackend_1   |     raise FieldError('Related Field got invalid lookup: {}'.format(lookup_name))\r\nbackend_1   | django.core.exceptions.FieldError: Related Field got invalid lookup: icontains\r\nbackend_1   | [29/Jun/2020 12:25:49] \"GET /admin/api/document/?q=request HTTP/1.1\" 500 160618\r\n```\r\n\r\nIs this like https://stackoverflow.com/questions/11754877/troubleshooting-related-field-has-invalid-lookup-icontains?\r\n\r\nYour Environment\r\n---------\r\n<!-- Include details of your environment.-->\r\n*   Operating System: Calculate Linux 20.6\r\n*   Python Version Used: system Python version is 3.7.7\r\n*   When you install doccano: 4927a01f090b91d8e14e467f2fd40d8301612e72\r\n*   How did you install doccano (Heroku button etc): Docker Compose\r\n\n", "before_files": [{"content": "from django.contrib import admin\n\nfrom .models import Label, Document, Project\nfrom .models import Role, RoleMapping\nfrom .models import DocumentAnnotation, SequenceAnnotation, Seq2seqAnnotation\nfrom .models import TextClassificationProject, SequenceLabelingProject, Seq2seqProject\n\n\nclass LabelAdmin(admin.ModelAdmin):\n    list_display = ('text', 'project', 'text_color', 'background_color')\n    ordering = ('project',)\n    search_fields = ('project',)\n\n\nclass DocumentAdmin(admin.ModelAdmin):\n    list_display = ('text', 'project', 'meta')\n    ordering = ('project',)\n    search_fields = ('project',)\n\n\nclass ProjectAdmin(admin.ModelAdmin):\n    list_display = ('name', 'description', 'project_type', 'randomize_document_order', 'collaborative_annotation')\n    ordering = ('project_type',)\n    search_fields = ('name',)\n\n\nclass SequenceAnnotationAdmin(admin.ModelAdmin):\n    list_display = ('document', 'label', 'start_offset', 'user')\n    ordering = ('document',)\n    search_fields = ('document',)\n\n\nclass DocumentAnnotationAdmin(admin.ModelAdmin):\n    list_display = ('document', 'label', 'user')\n    ordering = ('document',)\n    search_fields = ('document',)\n\n\nclass Seq2seqAnnotationAdmin(admin.ModelAdmin):\n    list_display = ('document', 'text', 'user')\n    ordering = ('document',)\n    search_fields = ('document',)\n\n\nclass RoleAdmin(admin.ModelAdmin):\n    list_display = ('name', 'description')\n    ordering = ('name',)\n    search_fields = ('name',)\n\n\nclass RoleMappingAdmin(admin.ModelAdmin):\n    list_display = ('user', 'role', 'project', )\n    ordering = ('user',)\n    search_fields = ('user',)\n\n\nadmin.site.register(DocumentAnnotation, DocumentAnnotationAdmin)\nadmin.site.register(SequenceAnnotation, SequenceAnnotationAdmin)\nadmin.site.register(Seq2seqAnnotation, Seq2seqAnnotationAdmin)\nadmin.site.register(Label, LabelAdmin)\nadmin.site.register(Document, DocumentAdmin)\nadmin.site.register(Project, ProjectAdmin)\nadmin.site.register(TextClassificationProject, ProjectAdmin)\nadmin.site.register(SequenceLabelingProject, ProjectAdmin)\nadmin.site.register(Seq2seqProject, ProjectAdmin)\nadmin.site.register(Role, RoleAdmin)\nadmin.site.register(RoleMapping, RoleMappingAdmin)\n", "path": "app/api/admin.py"}], "after_files": [{"content": "from django.contrib import admin\n\nfrom .models import Label, Document, Project\nfrom .models import Role, RoleMapping\nfrom .models import DocumentAnnotation, SequenceAnnotation, Seq2seqAnnotation\nfrom .models import TextClassificationProject, SequenceLabelingProject, Seq2seqProject\n\n\nclass LabelAdmin(admin.ModelAdmin):\n    list_display = ('text', 'project', 'text_color', 'background_color')\n    ordering = ('project',)\n    search_fields = ('text',)\n\n\nclass DocumentAdmin(admin.ModelAdmin):\n    list_display = ('text', 'project', 'meta')\n    ordering = ('project',)\n    search_fields = ('text',)\n\n\nclass ProjectAdmin(admin.ModelAdmin):\n    list_display = ('name', 'description', 'project_type', 'randomize_document_order', 'collaborative_annotation')\n    ordering = ('project_type',)\n    search_fields = ('name',)\n\n\nclass SequenceAnnotationAdmin(admin.ModelAdmin):\n    list_display = ('document', 'label', 'start_offset', 'user')\n    ordering = ('document',)\n    search_fields = ('document__text',)\n\n\nclass DocumentAnnotationAdmin(admin.ModelAdmin):\n    list_display = ('document', 'label', 'user')\n    ordering = ('document',)\n    search_fields = ('document__text',)\n\n\nclass Seq2seqAnnotationAdmin(admin.ModelAdmin):\n    list_display = ('document', 'text', 'user')\n    ordering = ('document',)\n    search_fields = ('document__text',)\n\n\nclass RoleAdmin(admin.ModelAdmin):\n    list_display = ('name', 'description')\n    ordering = ('name',)\n    search_fields = ('name',)\n\n\nclass RoleMappingAdmin(admin.ModelAdmin):\n    list_display = ('user', 'role', 'project', )\n    ordering = ('user',)\n    search_fields = ('user__username',)\n\n\nadmin.site.register(DocumentAnnotation, DocumentAnnotationAdmin)\nadmin.site.register(SequenceAnnotation, SequenceAnnotationAdmin)\nadmin.site.register(Seq2seqAnnotation, Seq2seqAnnotationAdmin)\nadmin.site.register(Label, LabelAdmin)\nadmin.site.register(Document, DocumentAdmin)\nadmin.site.register(Project, ProjectAdmin)\nadmin.site.register(TextClassificationProject, ProjectAdmin)\nadmin.site.register(SequenceLabelingProject, ProjectAdmin)\nadmin.site.register(Seq2seqProject, ProjectAdmin)\nadmin.site.register(Role, RoleAdmin)\nadmin.site.register(RoleMapping, RoleMappingAdmin)\n", "path": "app/api/admin.py"}]}