这是我的models.py
class Picture(models.Model):
image = models.ImageField(upload_to='uploads/')
caption = models.CharField(max_length=140, null=True, blank=True)
uploaded = models.DateField()
comments = models.ManyToManyField(Comment, null=True, blank=True)
还有我的tastepie的API资源,api.py:
class PictureResource(ModelResource):
class Meta:
queryset = Picture.objects.all.order_by('-uploaded')
resource_name = "photo"
authorization = Authorization()
API_LIMIT_PER_PAGE = 24
如您所见,我希望我的 API 页面按上传的最新图像排序。
我的错误代码是:
函数对象没有属性“order_by”
通常我不知道该怎么办...
(顺便问一下,API_LIMIT_PER_PAGE = 24
这是在正确的地方吗?)