问题
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