Here is my 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)
And my tastypie’s API resources, api.py:
class PictureResource(ModelResource):
class Meta:
queryset = Picture.objects.all.order_by('-uploaded')
resource_name = "photo"
authorization = Authorization()
API_LIMIT_PER_PAGE = 24
As you see, I want my API page in order by latest image uploaded.
My error code is:
Function object has no attribute ‘order_by’
As usually I don’t know what to do…
(By the way, API_LIMIT_PER_PAGE = 24 is this in the right place?)
Change your
querysetto:allby itself it’s just a method, but if you use it likeall()it returns a QuerySet.order_byis a QuerySet method.