We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
Pagination for releases on Project Admin doesn't work
The pagination on releases does not appear to be functional in the project admin. It shows the first N releases, but when you click to see all, there is no pagination links and there is no text to indicate what page you're on or how many results there are.

Manually adding a ``?page=2`` *does* work, so this is likely just something wrong in the template.

--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `warehouse/admin/views/projects.py`
Content:
```
1 # Licensed under the Apache License, Version 2.0 (the "License");
2 # you may not use this file except in compliance with the License.
3 # You may obtain a copy of the License at
4 #
5 # http://www.apache.org/licenses/LICENSE-2.0
6 #
7 # Unless required by applicable law or agreed to in writing, software
8 # distributed under the License is distributed on an "AS IS" BASIS,
9 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10 # See the License for the specific language governing permissions and
11 # limitations under the License.
12 
13 import shlex
14 
15 from paginate_sqlalchemy import SqlalchemyOrmPage as SQLAlchemyORMPage
16 from pyramid.httpexceptions import (
17     HTTPBadRequest,
18     HTTPMovedPermanently,
19 )
20 from pyramid.view import view_config
21 from sqlalchemy import or_
22 
23 from warehouse.accounts.models import User
24 from warehouse.packaging.models import Project, Release, Role, JournalEntry
25 from warehouse.utils.paginate import paginate_url_factory
26 
27 
28 @view_config(
29     route_name="admin.project.list",
30     renderer="admin/projects/list.html",
31     permission="admin",
32     uses_session=True,
33 )
34 def project_list(request):
35     q = request.params.get("q")
36 
37     try:
38         page_num = int(request.params.get("page", 1))
39     except ValueError:
40         raise HTTPBadRequest("'page' must be an integer.") from None
41 
42     projects_query = request.db.query(Project).order_by(Project.name)
43 
44     if q:
45         terms = shlex.split(q)
46 
47         filters = []
48         for term in terms:
49             filters.append(Project.name.ilike(term))
50 
51         projects_query = projects_query.filter(or_(*filters))
52 
53     projects = SQLAlchemyORMPage(
54         projects_query,
55         page=page_num,
56         items_per_page=25,
57         url_maker=paginate_url_factory(request),
58     )
59 
60     return {"projects": projects, "query": q}
61 
62 
63 @view_config(route_name="admin.project.detail",
64              renderer="admin/projects/detail.html",
65              permission="admin",
66              uses_session=True,
67              require_csrf=True,
68              require_methods=False)
69 def project_detail(project, request):
70     project_name = request.matchdict["project_name"]
71 
72     if project_name != project.normalized_name:
73         raise HTTPMovedPermanently(
74             request.current_route_path(
75                 project_name=project.normalized_name,
76             ),
77         )
78 
79     maintainers = [
80         role
81         for role in (
82             request.db.query(Role)
83             .join(User)
84             .filter(Role.project == project)
85             .distinct(User.username)
86             .all()
87         )
88     ]
89     maintainers = sorted(
90         maintainers,
91         key=lambda x: (x.role_name, x.user.username),
92     )
93     journal = [
94         entry
95         for entry in (
96             request.db.query(JournalEntry)
97             .filter(JournalEntry.name == project.name)
98             .order_by(JournalEntry.submitted_date.desc())
99             .limit(50)
100         )
101     ]
102 
103     return {"project": project, "maintainers": maintainers, "journal": journal}
104 
105 
106 @view_config(
107     route_name="admin.project.releases",
108     renderer="admin/projects/releases_list.html",
109     permission="admin",
110     uses_session=True,
111 )
112 def releases_list(project, request):
113     q = request.params.get("q")
114     project_name = request.matchdict["project_name"]
115 
116     if project_name != project.normalized_name:
117         raise HTTPMovedPermanently(
118             request.current_route_path(
119                 project_name=project.normalized_name,
120             ),
121         )
122 
123     try:
124         page_num = int(request.params.get("page", 1))
125     except ValueError:
126         raise HTTPBadRequest("'page' must be an integer.") from None
127 
128     releases_query = (request.db.query(Release)
129                       .filter(Release.project == project)
130                       .order_by(Release._pypi_ordering.desc()))
131 
132     if q:
133         terms = shlex.split(q)
134 
135         filters = []
136         for term in terms:
137             if ":" in term:
138                 field, value = term.split(":", 1)
139                 if field.lower() == "version":
140                     filters.append(Release.version.ilike(value))
141 
142         releases_query = releases_query.filter(or_(*filters))
143 
144     releases = SQLAlchemyORMPage(
145         releases_query,
146         page=page_num,
147         items_per_page=25,
148         url_maker=paginate_url_factory(request),
149     )
150 
151     return {
152         "releases": list(releases),
153         "project": project,
154         "query": q,
155     }
156 
157 
158 @view_config(
159     route_name="admin.project.journals",
160     renderer="admin/projects/journals_list.html",
161     permission="admin",
162     uses_session=True,
163 )
164 def journals_list(project, request):
165     q = request.params.get("q")
166     project_name = request.matchdict["project_name"]
167 
168     if project_name != project.normalized_name:
169         raise HTTPMovedPermanently(
170             request.current_route_path(
171                 project_name=project.normalized_name,
172             ),
173         )
174 
175     try:
176         page_num = int(request.params.get("page", 1))
177     except ValueError:
178         raise HTTPBadRequest("'page' must be an integer.") from None
179 
180     journals_query = (request.db.query(JournalEntry)
181                       .filter(JournalEntry.name == project.name)
182                       .order_by(JournalEntry.submitted_date.desc()))
183 
184     if q:
185         terms = shlex.split(q)
186 
187         filters = []
188         for term in terms:
189             if ":" in term:
190                 field, value = term.split(":", 1)
191                 if field.lower() == "version":
192                     filters.append(JournalEntry.version.ilike(value))
193 
194         journals_query = journals_query.filter(or_(*filters))
195 
196     journals = SQLAlchemyORMPage(
197         journals_query,
198         page=page_num,
199         items_per_page=25,
200         url_maker=paginate_url_factory(request),
201     )
202 
203     return {"journals": journals, "project": project, "query": q}
204
```
--- 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/warehouse/admin/views/projects.py b/warehouse/admin/views/projects.py
--- a/warehouse/admin/views/projects.py
+++ b/warehouse/admin/views/projects.py
@@ -149,7 +149,7 @@
     )
 
     return {
-        "releases": list(releases),
+        "releases": releases,
         "project": project,
         "query": q,
     }

{"golden_diff": "diff --git a/warehouse/admin/views/projects.py b/warehouse/admin/views/projects.py\n--- a/warehouse/admin/views/projects.py\n+++ b/warehouse/admin/views/projects.py\n@@ -149,7 +149,7 @@\n     )\n \n     return {\n-        \"releases\": list(releases),\n+        \"releases\": releases,\n         \"project\": project,\n         \"query\": q,\n     }\n", "issue": "Pagination for releases on Project Admin doesn't work\nThe pagination on releases does not appear to be functional in the project admin. It shows the first N releases, but when you click to see all, there is no pagination links and there is no text to indicate what page you're on or how many results there are.\r\n\r\nManually adding a ``?page=2`` *does* work, so this is likely just something wrong in the template.\n", "before_files": [{"content": "# Licensed under the Apache License, Version 2.0 (the \"License\");\n# you may not use this file except in compliance with the License.\n# You may obtain a copy of the License at\n#\n# http://www.apache.org/licenses/LICENSE-2.0\n#\n# Unless required by applicable law or agreed to in writing, software\n# distributed under the License is distributed on an \"AS IS\" BASIS,\n# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n# See the License for the specific language governing permissions and\n# limitations under the License.\n\nimport shlex\n\nfrom paginate_sqlalchemy import SqlalchemyOrmPage as SQLAlchemyORMPage\nfrom pyramid.httpexceptions import (\n    HTTPBadRequest,\n    HTTPMovedPermanently,\n)\nfrom pyramid.view import view_config\nfrom sqlalchemy import or_\n\nfrom warehouse.accounts.models import User\nfrom warehouse.packaging.models import Project, Release, Role, JournalEntry\nfrom warehouse.utils.paginate import paginate_url_factory\n\n\n@view_config(\n    route_name=\"admin.project.list\",\n    renderer=\"admin/projects/list.html\",\n    permission=\"admin\",\n    uses_session=True,\n)\ndef project_list(request):\n    q = request.params.get(\"q\")\n\n    try:\n        page_num = int(request.params.get(\"page\", 1))\n    except ValueError:\n        raise HTTPBadRequest(\"'page' must be an integer.\") from None\n\n    projects_query = request.db.query(Project).order_by(Project.name)\n\n    if q:\n        terms = shlex.split(q)\n\n        filters = []\n        for term in terms:\n            filters.append(Project.name.ilike(term))\n\n        projects_query = projects_query.filter(or_(*filters))\n\n    projects = SQLAlchemyORMPage(\n        projects_query,\n        page=page_num,\n        items_per_page=25,\n        url_maker=paginate_url_factory(request),\n    )\n\n    return {\"projects\": projects, \"query\": q}\n\n\n@view_config(route_name=\"admin.project.detail\",\n             renderer=\"admin/projects/detail.html\",\n             permission=\"admin\",\n             uses_session=True,\n             require_csrf=True,\n             require_methods=False)\ndef project_detail(project, request):\n    project_name = request.matchdict[\"project_name\"]\n\n    if project_name != project.normalized_name:\n        raise HTTPMovedPermanently(\n            request.current_route_path(\n                project_name=project.normalized_name,\n            ),\n        )\n\n    maintainers = [\n        role\n        for role in (\n            request.db.query(Role)\n            .join(User)\n            .filter(Role.project == project)\n            .distinct(User.username)\n            .all()\n        )\n    ]\n    maintainers = sorted(\n        maintainers,\n        key=lambda x: (x.role_name, x.user.username),\n    )\n    journal = [\n        entry\n        for entry in (\n            request.db.query(JournalEntry)\n            .filter(JournalEntry.name == project.name)\n            .order_by(JournalEntry.submitted_date.desc())\n            .limit(50)\n        )\n    ]\n\n    return {\"project\": project, \"maintainers\": maintainers, \"journal\": journal}\n\n\n@view_config(\n    route_name=\"admin.project.releases\",\n    renderer=\"admin/projects/releases_list.html\",\n    permission=\"admin\",\n    uses_session=True,\n)\ndef releases_list(project, request):\n    q = request.params.get(\"q\")\n    project_name = request.matchdict[\"project_name\"]\n\n    if project_name != project.normalized_name:\n        raise HTTPMovedPermanently(\n            request.current_route_path(\n                project_name=project.normalized_name,\n            ),\n        )\n\n    try:\n        page_num = int(request.params.get(\"page\", 1))\n    except ValueError:\n        raise HTTPBadRequest(\"'page' must be an integer.\") from None\n\n    releases_query = (request.db.query(Release)\n                      .filter(Release.project == project)\n                      .order_by(Release._pypi_ordering.desc()))\n\n    if q:\n        terms = shlex.split(q)\n\n        filters = []\n        for term in terms:\n            if \":\" in term:\n                field, value = term.split(\":\", 1)\n                if field.lower() == \"version\":\n                    filters.append(Release.version.ilike(value))\n\n        releases_query = releases_query.filter(or_(*filters))\n\n    releases = SQLAlchemyORMPage(\n        releases_query,\n        page=page_num,\n        items_per_page=25,\n        url_maker=paginate_url_factory(request),\n    )\n\n    return {\n        \"releases\": list(releases),\n        \"project\": project,\n        \"query\": q,\n    }\n\n\n@view_config(\n    route_name=\"admin.project.journals\",\n    renderer=\"admin/projects/journals_list.html\",\n    permission=\"admin\",\n    uses_session=True,\n)\ndef journals_list(project, request):\n    q = request.params.get(\"q\")\n    project_name = request.matchdict[\"project_name\"]\n\n    if project_name != project.normalized_name:\n        raise HTTPMovedPermanently(\n            request.current_route_path(\n                project_name=project.normalized_name,\n            ),\n        )\n\n    try:\n        page_num = int(request.params.get(\"page\", 1))\n    except ValueError:\n        raise HTTPBadRequest(\"'page' must be an integer.\") from None\n\n    journals_query = (request.db.query(JournalEntry)\n                      .filter(JournalEntry.name == project.name)\n                      .order_by(JournalEntry.submitted_date.desc()))\n\n    if q:\n        terms = shlex.split(q)\n\n        filters = []\n        for term in terms:\n            if \":\" in term:\n                field, value = term.split(\":\", 1)\n                if field.lower() == \"version\":\n                    filters.append(JournalEntry.version.ilike(value))\n\n        journals_query = journals_query.filter(or_(*filters))\n\n    journals = SQLAlchemyORMPage(\n        journals_query,\n        page=page_num,\n        items_per_page=25,\n        url_maker=paginate_url_factory(request),\n    )\n\n    return {\"journals\": journals, \"project\": project, \"query\": q}\n", "path": "warehouse/admin/views/projects.py"}], "after_files": [{"content": "# Licensed under the Apache License, Version 2.0 (the \"License\");\n# you may not use this file except in compliance with the License.\n# You may obtain a copy of the License at\n#\n# http://www.apache.org/licenses/LICENSE-2.0\n#\n# Unless required by applicable law or agreed to in writing, software\n# distributed under the License is distributed on an \"AS IS\" BASIS,\n# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n# See the License for the specific language governing permissions and\n# limitations under the License.\n\nimport shlex\n\nfrom paginate_sqlalchemy import SqlalchemyOrmPage as SQLAlchemyORMPage\nfrom pyramid.httpexceptions import (\n    HTTPBadRequest,\n    HTTPMovedPermanently,\n)\nfrom pyramid.view import view_config\nfrom sqlalchemy import or_\n\nfrom warehouse.accounts.models import User\nfrom warehouse.packaging.models import Project, Release, Role, JournalEntry\nfrom warehouse.utils.paginate import paginate_url_factory\n\n\n@view_config(\n    route_name=\"admin.project.list\",\n    renderer=\"admin/projects/list.html\",\n    permission=\"admin\",\n    uses_session=True,\n)\ndef project_list(request):\n    q = request.params.get(\"q\")\n\n    try:\n        page_num = int(request.params.get(\"page\", 1))\n    except ValueError:\n        raise HTTPBadRequest(\"'page' must be an integer.\") from None\n\n    projects_query = request.db.query(Project).order_by(Project.name)\n\n    if q:\n        terms = shlex.split(q)\n\n        filters = []\n        for term in terms:\n            filters.append(Project.name.ilike(term))\n\n        projects_query = projects_query.filter(or_(*filters))\n\n    projects = SQLAlchemyORMPage(\n        projects_query,\n        page=page_num,\n        items_per_page=25,\n        url_maker=paginate_url_factory(request),\n    )\n\n    return {\"projects\": projects, \"query\": q}\n\n\n@view_config(route_name=\"admin.project.detail\",\n             renderer=\"admin/projects/detail.html\",\n             permission=\"admin\",\n             uses_session=True,\n             require_csrf=True,\n             require_methods=False)\ndef project_detail(project, request):\n    project_name = request.matchdict[\"project_name\"]\n\n    if project_name != project.normalized_name:\n        raise HTTPMovedPermanently(\n            request.current_route_path(\n                project_name=project.normalized_name,\n            ),\n        )\n\n    maintainers = [\n        role\n        for role in (\n            request.db.query(Role)\n            .join(User)\n            .filter(Role.project == project)\n            .distinct(User.username)\n            .all()\n        )\n    ]\n    maintainers = sorted(\n        maintainers,\n        key=lambda x: (x.role_name, x.user.username),\n    )\n    journal = [\n        entry\n        for entry in (\n            request.db.query(JournalEntry)\n            .filter(JournalEntry.name == project.name)\n            .order_by(JournalEntry.submitted_date.desc())\n            .limit(50)\n        )\n    ]\n\n    return {\"project\": project, \"maintainers\": maintainers, \"journal\": journal}\n\n\n@view_config(\n    route_name=\"admin.project.releases\",\n    renderer=\"admin/projects/releases_list.html\",\n    permission=\"admin\",\n    uses_session=True,\n)\ndef releases_list(project, request):\n    q = request.params.get(\"q\")\n    project_name = request.matchdict[\"project_name\"]\n\n    if project_name != project.normalized_name:\n        raise HTTPMovedPermanently(\n            request.current_route_path(\n                project_name=project.normalized_name,\n            ),\n        )\n\n    try:\n        page_num = int(request.params.get(\"page\", 1))\n    except ValueError:\n        raise HTTPBadRequest(\"'page' must be an integer.\") from None\n\n    releases_query = (request.db.query(Release)\n                      .filter(Release.project == project)\n                      .order_by(Release._pypi_ordering.desc()))\n\n    if q:\n        terms = shlex.split(q)\n\n        filters = []\n        for term in terms:\n            if \":\" in term:\n                field, value = term.split(\":\", 1)\n                if field.lower() == \"version\":\n                    filters.append(Release.version.ilike(value))\n\n        releases_query = releases_query.filter(or_(*filters))\n\n    releases = SQLAlchemyORMPage(\n        releases_query,\n        page=page_num,\n        items_per_page=25,\n        url_maker=paginate_url_factory(request),\n    )\n\n    return {\n        \"releases\": releases,\n        \"project\": project,\n        \"query\": q,\n    }\n\n\n@view_config(\n    route_name=\"admin.project.journals\",\n    renderer=\"admin/projects/journals_list.html\",\n    permission=\"admin\",\n    uses_session=True,\n)\ndef journals_list(project, request):\n    q = request.params.get(\"q\")\n    project_name = request.matchdict[\"project_name\"]\n\n    if project_name != project.normalized_name:\n        raise HTTPMovedPermanently(\n            request.current_route_path(\n                project_name=project.normalized_name,\n            ),\n        )\n\n    try:\n        page_num = int(request.params.get(\"page\", 1))\n    except ValueError:\n        raise HTTPBadRequest(\"'page' must be an integer.\") from None\n\n    journals_query = (request.db.query(JournalEntry)\n                      .filter(JournalEntry.name == project.name)\n                      .order_by(JournalEntry.submitted_date.desc()))\n\n    if q:\n        terms = shlex.split(q)\n\n        filters = []\n        for term in terms:\n            if \":\" in term:\n                field, value = term.split(\":\", 1)\n                if field.lower() == \"version\":\n                    filters.append(JournalEntry.version.ilike(value))\n\n        journals_query = journals_query.filter(or_(*filters))\n\n    journals = SQLAlchemyORMPage(\n        journals_query,\n        page=page_num,\n        items_per_page=25,\n        url_maker=paginate_url_factory(request),\n    )\n\n    return {\"journals\": journals, \"project\": project, \"query\": q}\n", "path": "warehouse/admin/views/projects.py"}]}