Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/django/23.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Django管理中的列排序_Django - Fatal编程技术网

Django管理中的列排序

Django管理中的列排序,django,Django,嘿,我有一个modelUserProfile,它与modelUser有一个OneToOneField关系。在adminpage中,我使用list\u display属性在显示User的同一位置显示UserProfile的一些字段。它们显示得很好,但不幸的是,它们不像User中的模型那样可排序。我可以单击列标题,对属于User的列进行排序,但不能对来自UserProfile的列进行排序。如何使它们可单击和排序?您需要将属性添加到列中。OP指的是列排序,而不是模型查询集的排序。

嘿,我有一个model
UserProfile
,它与model
User
有一个OneToOneField关系。在adminpage中,我使用
list\u display
属性在显示
User
的同一位置显示UserProfile的一些字段。它们显示得很好,但不幸的是,它们不像
User
中的模型那样可排序。我可以单击列标题,对属于
User
的列进行排序,但不能对来自
UserProfile
的列进行排序。如何使它们可单击和排序?

您需要将属性添加到列中。

OP指的是列排序,而不是模型查询集的排序。