Cannot order by time using model manager

自古美人都是妖i 提交于 2019-12-13 04:22:24

问题


I made the following model manager

class TaskManager(models.Manager):
    def get_queryset(self):
        return super(TaskManager,self).get_queryset().order_by('time__hour')

But there is an error which says Cannot resolve keyword u'hour' into field. Join on 'time' not permitted.

My models.py looks something like this -

class Task(models.Model):
    content = models.TextField()
    slug = AutoSlugField(populate_from='content')
    time = models.DateTimeField()

    objects = TaskManager()

I don't know what I am doing wrong. Please help how should I go about doing this.

来源:https://stackoverflow.com/questions/47901991/cannot-order-by-time-using-model-manager

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!