python
data_error
ai_generated
true
django.core.exceptions.FieldError: 无法将关键字'name'解析为字段。选择有:id, created_at
django.core.exceptions.FieldError: Cannot resolve keyword 'name' into field. Choices are: id, created_at
ID: python/django-queryset-order-by-error
80%修复率
88%置信度
0证据数
2024-01-05首次发现
版本兼容性
| 版本 | 状态 | 引入 | 弃用 | 备注 |
|---|---|---|---|---|
| 3.x | active | — | — | — |
根因分析
在order_by()中使用模型上不存在的字段。
English
Using order_by() with a field that does not exist on the model.
解决方案
-
95% 成功率
Check model fields and use correct field: MyModel.objects.order_by('created_at') -
90% 成功率
Use related field with double underscore: order_by('related__field')
无效尝试
常见但无效的做法:
-
70% 失败
May not provide desired ordering.
-
80% 失败
Hides error, may break functionality.