Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

Ordering '/api/projects' with 'list_id' or 'list_name' doesn't work

未关闭
#318 1 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

评估

难度
2/5
预计耗时
1-3 小时
新手友好度
45/100
Issue 类型
缺陷
描述清晰度
描述清楚
活跃度
停滞
技术栈
python
领域
api, backend

调研方向

从 patchwork/api/project.py 中的 ProjectList 开始,检查 /api/projects 使用的 ordering_fields。重新实现按 list_id 和 list_name 排序,然后验证该端点在升序和降序请求下不再引发报告中的 FieldError。

由索引模型根据 Issue 内容生成。

描述

api bug

If you set the ordering filter to list_id ascending/descending or list_name ascending/descending in /api/projects, the following exception will be thrown:

FieldError at /api/projects/

Cannot resolve keyword 'link_name' into field. Choices are: bundle, delegationrule, id, linkname, listemail, listid, maintainer_project, name, patch, scm_url, send_notifications, series, subject_match, submission, use_tags, web_url, webscm_url

Suggested fix:

diff --git a/patchwork/api/project.py b/patchwork/api/project.py
index 3609f73..c249f54 100644
--- a/patchwork/api/project.py
+++ b/patchwork/api/project.py
@@ -83,7 +83,7 @@ class ProjectList(ProjectMixin, ListAPIView):

     search_fields = ('link_name', 'list_id', 'list_email', 'web_url',
                      'scm_url', 'webscm_url')
-    ordering_fields = ('id', 'name', 'link_name', 'list_id')
+    ordering_fields = ('id', 'name', 'linkname', 'listid')
     ordering = 'id'

Does this fix look good enough? Should I send a patch?

主要语言
Python
星标
317
派生
91
PR 合并指标
30 天内没有已合并 PR

贡献指南

打开贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

getpatchwork/patchwork 的其他 Issue

查看 getpatchwork/patchwork 的全部 Issue

相似的 Issue

更多 Python Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。