November 2015
Beginner to intermediate
840 pages
26h 30m
English
As with all Django tools, the quickest way to discover how to use the tool is to pop open the shell and start fooling around. Use the command in Example 14.1.
Example 14.1: Shell Code
$ ./manage.py
Let’s start by splitting up our tag list webpage. At the moment, we have 16 Tag objects in our database, as shown in Example 14.2.
Example 14.2: Python Interpreter Code
>>> from organizer.models import Tag >>> Tag.objects.count() 16
If we did not know about the Pagination class, we could start by slicing our queryset ourselves. In Example 14.3, we ask for all 16 Tag objects, and then use a slice to take the first five.
Example 14.3: Python Interpreter Code
Read now
Unlock full access