JosephConrad
JosephConrad

Reputation: 688

Django `object of type 'instancemethod' has no len()`

I have a following code in django:

def index(request):
    template_name = 'desks.html'

   # query = Desk.objects.all()

    desk_list = Desk.objects.all

    paginator = Paginator(desk_list, 5)
    page = paginator.page(1)

    return render_to_response(template_name, {'desk_list': page}, )

Unfortunately, I get the following error: object of type 'instancemethod' has no len()

At my model, I have defined only attributes.

Any idea what a mistake it can be?

Upvotes: 0

Views: 2510

Answers (1)

Blender
Blender

Reputation: 298432

You probably want to call all:

desk_list = Desk.objects.all()

Upvotes: 7

Related Questions