We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
Update django-filter to 1.0
## Details

Sorry for deleting the issue template: This is about technical debt :) It may not be immediately critical, but the advice from the author of django-filter is that it's worth it.

django-filter 1.0 has changes that are backwards incompatible. The release notes are here:

http://django-filter.readthedocs.io/en/latest/migration.html

It means, amongst other this, that all where  `Filter` object instances are iterated on, we have to [add the `.qs` method](http://django-filter.readthedocs.io/en/latest/migration.html#queryset-methods-are-no-longer-proxied).
Pin django-filter
The new 1.0 series is incompatible, and I've opened #2498 for this purpose.

Meanwhile, as the current master is broken because of this, the version should be pinned - I guess it's sort of bad practice to use the `master` branch anyways, am thinking it's possibly also an outdated decision now.

This fixes #2495 and #2490

--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `readthedocs/builds/filters.py`
Content:
```
1 from django.utils.translation import ugettext_lazy as _
2 
3 import django_filters
4 
5 from readthedocs.builds import constants
6 from readthedocs.builds.models import Build, Version
7 
8 
9 ANY_REPO = (
10     ('', _('Any')),
11 )
12 
13 BUILD_TYPES = ANY_REPO + constants.BUILD_TYPES
14 
15 
16 class VersionSlugFilter(django_filters.FilterSet):
17 
18     class Meta:
19         model = Version
20         fields = {
21             'identifier': ['icontains'],
22             'slug': ['icontains'],
23         }
24 
25 
26 class VersionFilter(django_filters.FilterSet):
27     project = django_filters.CharFilter(name='project__slug')
28     # Allow filtering on slug= or version=
29     slug = django_filters.CharFilter(label=_("Name"), name='slug',
30                                      lookup_type='exact')
31     version = django_filters.CharFilter(label=_("Version"), name='slug',
32                                         lookup_type='exact')
33 
34     class Meta:
35         model = Version
36         fields = ['project', 'slug', 'version']
37 
38 
39 class BuildFilter(django_filters.FilterSet):
40     date = django_filters.DateRangeFilter(label=_("Build Date"), name="date", lookup_type='range')
41     type = django_filters.ChoiceFilter(label=_("Build Type"),
42                                        choices=BUILD_TYPES)
43 
44     class Meta:
45         model = Build
46         fields = ['type', 'date', 'success']
47
```

Path: `readthedocs/projects/filters.py`
Content:
```
1 """Project query filters"""
2 
3 from django.utils.translation import ugettext_lazy as _
4 
5 import django_filters
6 
7 from readthedocs.projects import constants
8 from readthedocs.projects.models import Project, Domain
9 
10 ANY_REPO = (
11     ('', _('Any')),
12 )
13 
14 REPO_CHOICES = ANY_REPO + constants.REPO_CHOICES
15 
16 
17 def sort_slug(queryset, query):
18     """Fuzzy filter for slug fields
19 
20     Returns sorted queryset where slug approximates ``query``
21     """
22     queryset = queryset.filter(slug__icontains=query)
23     ret = []
24     ret.extend([q.pk for q in queryset
25                 if q.slug == query])
26     ret.extend([q.pk for q in queryset
27                 if q.slug.startswith(query) and q.pk not in ret])
28     ret.extend([q.pk for q in queryset
29                 if q.slug.endswith(query) and q.pk not in ret])
30     ret.extend([q.pk for q in queryset
31                 if q.pk not in ret])
32 
33     # Create a QS preserving ordering
34     clauses = ' '.join(['WHEN projects_project.id=%s THEN %s' % (pk, i)
35                         for i, pk in enumerate(ret)])
36     ordering = 'CASE %s END' % clauses
37     ret_queryset = Project.objects.filter(pk__in=ret).extra(
38         select={'ordering': ordering}, order_by=('ordering',))
39     return ret_queryset
40 
41 
42 class ProjectFilter(django_filters.FilterSet):
43 
44     """Project filter for filter views"""
45 
46     name = django_filters.CharFilter(label=_("Name"), name='name',
47                                      lookup_type='icontains')
48     slug = django_filters.CharFilter(label=_("Slug"), name='slug',
49                                      lookup_type='icontains')
50     pub_date = django_filters.DateRangeFilter(label=_("Created Date"),
51                                               name="pub_date")
52     repo = django_filters.CharFilter(label=_("Repository URL"), name='repo',
53                                      lookup_type='icontains')
54     repo_type = django_filters.ChoiceFilter(
55         label=_("Repository Type"),
56         name='repo',
57         lookup_type='icontains',
58         choices=REPO_CHOICES,
59     )
60 
61     class Meta:
62         model = Project
63         fields = ['name', 'slug', 'pub_date', 'repo', 'repo_type']
64 
65 
66 class DomainFilter(django_filters.FilterSet):
67     project = django_filters.CharFilter(label=_("Project"), name='project__slug',
68                                         lookup_type='exact')
69 
70     class Meta:
71         model = Domain
72         fields = ['domain', 'project', 'canonical']
73
```
--- 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/readthedocs/builds/filters.py b/readthedocs/builds/filters.py
--- a/readthedocs/builds/filters.py
+++ b/readthedocs/builds/filters.py
@@ -27,9 +27,9 @@
     project = django_filters.CharFilter(name='project__slug')
     # Allow filtering on slug= or version=
     slug = django_filters.CharFilter(label=_("Name"), name='slug',
-                                     lookup_type='exact')
+                                     lookup_expr='exact')
     version = django_filters.CharFilter(label=_("Version"), name='slug',
-                                        lookup_type='exact')
+                                        lookup_expr='exact')
 
     class Meta:
         model = Version
@@ -37,7 +37,7 @@
 
 
 class BuildFilter(django_filters.FilterSet):
-    date = django_filters.DateRangeFilter(label=_("Build Date"), name="date", lookup_type='range')
+    date = django_filters.DateRangeFilter(label=_("Build Date"), name="date", lookup_expr='range')
     type = django_filters.ChoiceFilter(label=_("Build Type"),
                                        choices=BUILD_TYPES)
 
diff --git a/readthedocs/projects/filters.py b/readthedocs/projects/filters.py
--- a/readthedocs/projects/filters.py
+++ b/readthedocs/projects/filters.py
@@ -44,17 +44,17 @@
     """Project filter for filter views"""
 
     name = django_filters.CharFilter(label=_("Name"), name='name',
-                                     lookup_type='icontains')
+                                     lookup_expr='icontains')
     slug = django_filters.CharFilter(label=_("Slug"), name='slug',
-                                     lookup_type='icontains')
+                                     lookup_expr='icontains')
     pub_date = django_filters.DateRangeFilter(label=_("Created Date"),
                                               name="pub_date")
     repo = django_filters.CharFilter(label=_("Repository URL"), name='repo',
-                                     lookup_type='icontains')
+                                     lookup_expr='icontains')
     repo_type = django_filters.ChoiceFilter(
         label=_("Repository Type"),
         name='repo',
-        lookup_type='icontains',
+        lookup_expr='icontains',
         choices=REPO_CHOICES,
     )
 
@@ -65,7 +65,7 @@
 
 class DomainFilter(django_filters.FilterSet):
     project = django_filters.CharFilter(label=_("Project"), name='project__slug',
-                                        lookup_type='exact')
+                                        lookup_expr='exact')
 
     class Meta:
         model = Domain

{"golden_diff": "diff --git a/readthedocs/builds/filters.py b/readthedocs/builds/filters.py\n--- a/readthedocs/builds/filters.py\n+++ b/readthedocs/builds/filters.py\n@@ -27,9 +27,9 @@\n     project = django_filters.CharFilter(name='project__slug')\n     # Allow filtering on slug= or version=\n     slug = django_filters.CharFilter(label=_(\"Name\"), name='slug',\n-                                     lookup_type='exact')\n+                                     lookup_expr='exact')\n     version = django_filters.CharFilter(label=_(\"Version\"), name='slug',\n-                                        lookup_type='exact')\n+                                        lookup_expr='exact')\n \n     class Meta:\n         model = Version\n@@ -37,7 +37,7 @@\n \n \n class BuildFilter(django_filters.FilterSet):\n-    date = django_filters.DateRangeFilter(label=_(\"Build Date\"), name=\"date\", lookup_type='range')\n+    date = django_filters.DateRangeFilter(label=_(\"Build Date\"), name=\"date\", lookup_expr='range')\n     type = django_filters.ChoiceFilter(label=_(\"Build Type\"),\n                                        choices=BUILD_TYPES)\n \ndiff --git a/readthedocs/projects/filters.py b/readthedocs/projects/filters.py\n--- a/readthedocs/projects/filters.py\n+++ b/readthedocs/projects/filters.py\n@@ -44,17 +44,17 @@\n     \"\"\"Project filter for filter views\"\"\"\n \n     name = django_filters.CharFilter(label=_(\"Name\"), name='name',\n-                                     lookup_type='icontains')\n+                                     lookup_expr='icontains')\n     slug = django_filters.CharFilter(label=_(\"Slug\"), name='slug',\n-                                     lookup_type='icontains')\n+                                     lookup_expr='icontains')\n     pub_date = django_filters.DateRangeFilter(label=_(\"Created Date\"),\n                                               name=\"pub_date\")\n     repo = django_filters.CharFilter(label=_(\"Repository URL\"), name='repo',\n-                                     lookup_type='icontains')\n+                                     lookup_expr='icontains')\n     repo_type = django_filters.ChoiceFilter(\n         label=_(\"Repository Type\"),\n         name='repo',\n-        lookup_type='icontains',\n+        lookup_expr='icontains',\n         choices=REPO_CHOICES,\n     )\n \n@@ -65,7 +65,7 @@\n \n class DomainFilter(django_filters.FilterSet):\n     project = django_filters.CharFilter(label=_(\"Project\"), name='project__slug',\n-                                        lookup_type='exact')\n+                                        lookup_expr='exact')\n \n     class Meta:\n         model = Domain\n", "issue": "Update django-filter to 1.0\n## Details\r\n\r\nSorry for deleting the issue template: This is about technical debt :) It may not be immediately critical, but the advice from the author of django-filter is that it's worth it.\r\n\r\ndjango-filter 1.0 has changes that are backwards incompatible. The release notes are here:\r\n\r\nhttp://django-filter.readthedocs.io/en/latest/migration.html\r\n\r\nIt means, amongst other this, that all where  `Filter` object instances are iterated on, we have to [add the `.qs` method](http://django-filter.readthedocs.io/en/latest/migration.html#queryset-methods-are-no-longer-proxied).\nPin django-filter\nThe new 1.0 series is incompatible, and I've opened #2498 for this purpose.\r\n\r\nMeanwhile, as the current master is broken because of this, the version should be pinned - I guess it's sort of bad practice to use the `master` branch anyways, am thinking it's possibly also an outdated decision now.\r\n\r\nThis fixes #2495 and #2490\n", "before_files": [{"content": "from django.utils.translation import ugettext_lazy as _\n\nimport django_filters\n\nfrom readthedocs.builds import constants\nfrom readthedocs.builds.models import Build, Version\n\n\nANY_REPO = (\n    ('', _('Any')),\n)\n\nBUILD_TYPES = ANY_REPO + constants.BUILD_TYPES\n\n\nclass VersionSlugFilter(django_filters.FilterSet):\n\n    class Meta:\n        model = Version\n        fields = {\n            'identifier': ['icontains'],\n            'slug': ['icontains'],\n        }\n\n\nclass VersionFilter(django_filters.FilterSet):\n    project = django_filters.CharFilter(name='project__slug')\n    # Allow filtering on slug= or version=\n    slug = django_filters.CharFilter(label=_(\"Name\"), name='slug',\n                                     lookup_type='exact')\n    version = django_filters.CharFilter(label=_(\"Version\"), name='slug',\n                                        lookup_type='exact')\n\n    class Meta:\n        model = Version\n        fields = ['project', 'slug', 'version']\n\n\nclass BuildFilter(django_filters.FilterSet):\n    date = django_filters.DateRangeFilter(label=_(\"Build Date\"), name=\"date\", lookup_type='range')\n    type = django_filters.ChoiceFilter(label=_(\"Build Type\"),\n                                       choices=BUILD_TYPES)\n\n    class Meta:\n        model = Build\n        fields = ['type', 'date', 'success']\n", "path": "readthedocs/builds/filters.py"}, {"content": "\"\"\"Project query filters\"\"\"\n\nfrom django.utils.translation import ugettext_lazy as _\n\nimport django_filters\n\nfrom readthedocs.projects import constants\nfrom readthedocs.projects.models import Project, Domain\n\nANY_REPO = (\n    ('', _('Any')),\n)\n\nREPO_CHOICES = ANY_REPO + constants.REPO_CHOICES\n\n\ndef sort_slug(queryset, query):\n    \"\"\"Fuzzy filter for slug fields\n\n    Returns sorted queryset where slug approximates ``query``\n    \"\"\"\n    queryset = queryset.filter(slug__icontains=query)\n    ret = []\n    ret.extend([q.pk for q in queryset\n                if q.slug == query])\n    ret.extend([q.pk for q in queryset\n                if q.slug.startswith(query) and q.pk not in ret])\n    ret.extend([q.pk for q in queryset\n                if q.slug.endswith(query) and q.pk not in ret])\n    ret.extend([q.pk for q in queryset\n                if q.pk not in ret])\n\n    # Create a QS preserving ordering\n    clauses = ' '.join(['WHEN projects_project.id=%s THEN %s' % (pk, i)\n                        for i, pk in enumerate(ret)])\n    ordering = 'CASE %s END' % clauses\n    ret_queryset = Project.objects.filter(pk__in=ret).extra(\n        select={'ordering': ordering}, order_by=('ordering',))\n    return ret_queryset\n\n\nclass ProjectFilter(django_filters.FilterSet):\n\n    \"\"\"Project filter for filter views\"\"\"\n\n    name = django_filters.CharFilter(label=_(\"Name\"), name='name',\n                                     lookup_type='icontains')\n    slug = django_filters.CharFilter(label=_(\"Slug\"), name='slug',\n                                     lookup_type='icontains')\n    pub_date = django_filters.DateRangeFilter(label=_(\"Created Date\"),\n                                              name=\"pub_date\")\n    repo = django_filters.CharFilter(label=_(\"Repository URL\"), name='repo',\n                                     lookup_type='icontains')\n    repo_type = django_filters.ChoiceFilter(\n        label=_(\"Repository Type\"),\n        name='repo',\n        lookup_type='icontains',\n        choices=REPO_CHOICES,\n    )\n\n    class Meta:\n        model = Project\n        fields = ['name', 'slug', 'pub_date', 'repo', 'repo_type']\n\n\nclass DomainFilter(django_filters.FilterSet):\n    project = django_filters.CharFilter(label=_(\"Project\"), name='project__slug',\n                                        lookup_type='exact')\n\n    class Meta:\n        model = Domain\n        fields = ['domain', 'project', 'canonical']\n", "path": "readthedocs/projects/filters.py"}], "after_files": [{"content": "from django.utils.translation import ugettext_lazy as _\n\nimport django_filters\n\nfrom readthedocs.builds import constants\nfrom readthedocs.builds.models import Build, Version\n\n\nANY_REPO = (\n    ('', _('Any')),\n)\n\nBUILD_TYPES = ANY_REPO + constants.BUILD_TYPES\n\n\nclass VersionSlugFilter(django_filters.FilterSet):\n\n    class Meta:\n        model = Version\n        fields = {\n            'identifier': ['icontains'],\n            'slug': ['icontains'],\n        }\n\n\nclass VersionFilter(django_filters.FilterSet):\n    project = django_filters.CharFilter(name='project__slug')\n    # Allow filtering on slug= or version=\n    slug = django_filters.CharFilter(label=_(\"Name\"), name='slug',\n                                     lookup_expr='exact')\n    version = django_filters.CharFilter(label=_(\"Version\"), name='slug',\n                                        lookup_expr='exact')\n\n    class Meta:\n        model = Version\n        fields = ['project', 'slug', 'version']\n\n\nclass BuildFilter(django_filters.FilterSet):\n    date = django_filters.DateRangeFilter(label=_(\"Build Date\"), name=\"date\", lookup_expr='range')\n    type = django_filters.ChoiceFilter(label=_(\"Build Type\"),\n                                       choices=BUILD_TYPES)\n\n    class Meta:\n        model = Build\n        fields = ['type', 'date', 'success']\n", "path": "readthedocs/builds/filters.py"}, {"content": "\"\"\"Project query filters\"\"\"\n\nfrom django.utils.translation import ugettext_lazy as _\n\nimport django_filters\n\nfrom readthedocs.projects import constants\nfrom readthedocs.projects.models import Project, Domain\n\nANY_REPO = (\n    ('', _('Any')),\n)\n\nREPO_CHOICES = ANY_REPO + constants.REPO_CHOICES\n\n\ndef sort_slug(queryset, query):\n    \"\"\"Fuzzy filter for slug fields\n\n    Returns sorted queryset where slug approximates ``query``\n    \"\"\"\n    queryset = queryset.filter(slug__icontains=query)\n    ret = []\n    ret.extend([q.pk for q in queryset\n                if q.slug == query])\n    ret.extend([q.pk for q in queryset\n                if q.slug.startswith(query) and q.pk not in ret])\n    ret.extend([q.pk for q in queryset\n                if q.slug.endswith(query) and q.pk not in ret])\n    ret.extend([q.pk for q in queryset\n                if q.pk not in ret])\n\n    # Create a QS preserving ordering\n    clauses = ' '.join(['WHEN projects_project.id=%s THEN %s' % (pk, i)\n                        for i, pk in enumerate(ret)])\n    ordering = 'CASE %s END' % clauses\n    ret_queryset = Project.objects.filter(pk__in=ret).extra(\n        select={'ordering': ordering}, order_by=('ordering',))\n    return ret_queryset\n\n\nclass ProjectFilter(django_filters.FilterSet):\n\n    \"\"\"Project filter for filter views\"\"\"\n\n    name = django_filters.CharFilter(label=_(\"Name\"), name='name',\n                                     lookup_expr='icontains')\n    slug = django_filters.CharFilter(label=_(\"Slug\"), name='slug',\n                                     lookup_expr='icontains')\n    pub_date = django_filters.DateRangeFilter(label=_(\"Created Date\"),\n                                              name=\"pub_date\")\n    repo = django_filters.CharFilter(label=_(\"Repository URL\"), name='repo',\n                                     lookup_expr='icontains')\n    repo_type = django_filters.ChoiceFilter(\n        label=_(\"Repository Type\"),\n        name='repo',\n        lookup_expr='icontains',\n        choices=REPO_CHOICES,\n    )\n\n    class Meta:\n        model = Project\n        fields = ['name', 'slug', 'pub_date', 'repo', 'repo_type']\n\n\nclass DomainFilter(django_filters.FilterSet):\n    project = django_filters.CharFilter(label=_(\"Project\"), name='project__slug',\n                                        lookup_expr='exact')\n\n    class Meta:\n        model = Domain\n        fields = ['domain', 'project', 'canonical']\n", "path": "readthedocs/projects/filters.py"}]}