Novice questions about Pagination syntax and classes in general

27 views
Skip to first unread message

drone4four

unread,
Jun 1, 2019, 9:08:15 PM6/1/19
to Django users

As part of the official Django doc on Pagination, take a look at the listing function:


def listing(request):
    contact_list
= Contacts.objects.all()
    paginator
= Paginator(contact_list, 25) # Show 25 contacts per page


My two questions are:

  1. Is it possible to return more than one value when a function is assigned to a variable, like at line 3?

  2. At line 2, is `objects` a method within the Contacts class? If so, where is the Contacts class defined? It’s not imported at the top of the example views.py also in that Django doc above where I got this code sample.

John Bagiliko

unread,
Jun 2, 2019, 12:40:51 AM6/2/19
to django...@googlegroups.com
I will answer question two. I'm not sure I understand your question 1. The "objects" is query method of every Django model. You use it to query. Contacts should be in your models.py and you should import  Contacts in your views.py before you can use it.

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users...@googlegroups.com.
To post to this group, send email to django...@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/3540a14b-ef8a-4de3-ad59-858ca1c2a7c4%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages