简体   繁体   English

如何根据创建时间在django管理页面中订购本地django用户?

[英]How can I order the native django users in the django admin page based on creation time?

I wanted to know if there was a way of ordering the Django users on the django admin page based on creation time rather than alphabetical order. 我想知道是否有一种方法可以根据创建时间而不是字母顺序在django管理页面上对Django用户进行排序。 To be honest, it can be ordered by creation time or the id. 老实说,可以通过创建时间或ID对其进行排序。 But the order needs to be from latest users to the oldest. 但是顺序必须是从最新的用户到最早的用户。

I've done some research about ordering objects on the Admin page. 我已经对“管理”页面上的对象排序进行了一些研究。 I saw one source mentioning date hierarchy. 我看到一个来源提到日期层次结构。 Problem is I don't know the specific field to which the Django User can be ordered by. 问题是我不知道可以将Django用户订购的具体字段。

Do you have any solutions? 你有什么解决方案?

Thanks 谢谢

Shouldn't it just be: 不应该只是:

ordering = ['-date_joined']

You can order by any field the model gives you. 您可以按模型提供的任何字段订购。 Since you didn't specify the UserModel you are using, I guess you are talking about the BaseUser? 由于您没有指定要使用的UserModel,所以我猜您是在谈论BaseUser吗? If so, you can order by: 如果是这样,您可以通过以下方式订购:

  • first_name 名字
  • last_name
  • id ID
  • email 电子邮件
  • date_joined 加入日期
  • username 用户名
  • [is_staff] # bool [is_staff]#布尔
  • [is_active] # bool [is_active]#bool

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM