【发布时间】:2020-08-09 00:26:20
【问题描述】:
目前我的模型包含以下数据,
--------------------------
| id | playlist_name |
--------------------------
| 1 | 1st |
--------------------------
| 2 | hello1 |
--------------------------
| 3 | hello1 |
--------------------------
| 4 | gfh |
--------------------------
| 5 | gfh |
--------------------------
| 6 | ertr |
--------------------------
| 7 | dg |
--------------------------
我想得到没有重复播放列表名称的结果,有点像下面的结果
--------------------------
| id | playlist_name |
--------------------------
| 1 | 1st |
--------------------------
| 2 | hello1 |
--------------------------
| 4 | gfh |
--------------------------
| 6 | ertr |
--------------------------
| 7 | dg |
--------------------------
怎么做?谢谢。
【问题讨论】:
-
您可以为此目的使用
distinct('playlist_name')。见this。 -
raise NotSupportedError('DISTINCT ON fields is not supported by this database backend') django.db.utils.NotSupportedError: DISTINCT ON fields is not supported by this database backend
标签: mysql django django-models