Django Admin: Ordering of ForeignKey and ManyToManyField relations referencing User

后端 未结 4 1149
情书的邮戳
情书的邮戳 2020-11-30 04:42

I have an application that makes use of Django\'s UserProfile to extend the built-in Django User model. Looks a bit like:

class Us         


        
4条回答
  •  夕颜
    夕颜 (楼主)
    2020-11-30 05:36

    This

    class Meta:
        ordering = ['username']
    

    should be

        ordering = ['user__username']
    

    if it's in your UserProfile admin class. That'll stop the exception, but I don't think it helps you.

    Ordering the User model as you describe is quite tricky, but see http://code.djangoproject.com/ticket/6089#comment:8 for a solution.

提交回复
热议问题