Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7816363
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T05:50:28+00:00 2026-06-02T05:50:28+00:00

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)

  • 0

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?)

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T05:50:30+00:00Added an answer on June 2, 2026 at 5:50 am

    Change your queryset to:

    class PictureResource(ModelResource):
    
        class Meta:
            queryset = Picture.objects.all().order_by('-uploaded')
            resource_name = "photo"
            authorization = Authorization()
            API_LIMIT_PER_PAGE = 24
    

    all by itself it’s just a method, but if you use it like all() it returns a QuerySet. order_by is a QuerySet method.

    >> type(Picture.objects.all)
    <type 'instancemethod'>
    
    >> type(Picture.objects.all())
    <class 'django.db.models.query.QuerySet'>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Here is a Django model I'm using. class Person(models.Model): surname = models.CharField(max_length=255, null=True, blank=True)
Here is my models, class Age(models.Model): layer = models.CharField(max_length=50) order = models.PositiveIntegerField() ... class
Here are my models: class Groups(models.Model): group_id = models.AutoField(primary_key=True) group_name = models.CharField(max_length=20,db_index=True) #Some other
Here some models: class UserProfile(models.Model): name = models.CharField(max_length=30) email = models.EmailField(unique=True, db_index=True) birthday =
Here's part of my Django app's models.py : class Person(models.Model): birth_year = WideYear(null=True, blank=True)
I have the following in models.py: class Choices(models.Model): description = models.CharField(max_length=300) def __unicode__(self): return
I have a model like this: class Item(models.Model): code = models.CharField(max_length=200, unique=True) barcode =
Trying to work with ImageField in django. Here are my models class Album(models.Model): title
Here is a simplified version of one of my models: class ImportRule(models.Model): feed =
Okay so I have this mode: class Posts(db.Model): rand1 = db.FloatProperty() #other models here

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.