0
0
Djangoframework~10 mins

Pagination (PageNumber, Cursor, Limit/Offset) in Django - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to import the Django paginator class.

Django
from django.core.paginator import [1]
Drag options to blanks, or click blank then click option'
APaginator
BLimitOffsetPagination
CCursorPagination
DPage
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'Page' instead of 'Paginator' which is not the main class.
Confusing cursor or limit-offset pagination classes with Paginator.
2fill in blank
medium

Complete the code to create a paginator with 10 items per page.

Django
paginator = Paginator(queryset, [1])
Drag options to blanks, or click blank then click option'
A5
B20
C25
D10
Attempts:
3 left
💡 Hint
Common Mistakes
Using 5 or 20 which are valid but not the intended answer here.
Passing the queryset instead of the number.
3fill in blank
hard

Fix the error in retrieving the page object by filling the blank with the correct method call.

Django
page_obj = paginator.[1](page_number)
Drag options to blanks, or click blank then click option'
Aget_page_number
Bpage_number
Cget_page
Dpaginate
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'page_number' which is a variable, not a method.
Using 'paginate' which is not a method of Paginator.
4fill in blank
hard

Fill both blanks to create a cursor pagination class with a page size of 15.

Django
class MyCursorPagination([1]):
    page_size = [2]
Drag options to blanks, or click blank then click option'
ACursorPagination
BLimitOffsetPagination
C15
D10
Attempts:
3 left
💡 Hint
Common Mistakes
Using LimitOffsetPagination instead of CursorPagination.
Setting page_size to 10 instead of 15.
5fill in blank
hard

Fill all three blanks to create a limit-offset pagination class with default limit 20 and max limit 50.

Django
class MyLimitOffsetPagination([1]):
    default_limit = [2]
    max_limit = [3]
Drag options to blanks, or click blank then click option'
ALimitOffsetPagination
B20
C50
DCursorPagination
Attempts:
3 left
💡 Hint
Common Mistakes
Using CursorPagination instead of LimitOffsetPagination.
Mixing up default_limit and max_limit values.