<s> from random import choice <EOL> from django . shortcuts import render <EOL> from django . utils . lorem_ipsum import words <EOL> from django_tables2 import RequestConfig , SingleTableView <EOL> from . models import Country , Person <EOL> from . tables import BootstrapTable , CountryTable , ThemedCountryTable <EOL> def multiple ( request ) : <EOL> qs = Country . objects . all ( ) <EOL> example1 = CountryTable ( qs , prefix = "<STR_LIT>" ) <EOL> RequestConfig ( request , paginate = False ) . configure ( example1 ) <EOL> example2 = CountryTable ( qs , prefix = "<STR_LIT>" ) <EOL> RequestConfig ( request , paginate = { "<STR_LIT>" : <NUM_LIT:2> } ) . configure ( example2 ) <EOL> example3 = ThemedCountryTable ( qs , prefix = "<STR_LIT>" ) <EOL> RequestConfig ( request , paginate = { "<STR_LIT>" : <NUM_LIT:3> } ) . configure ( example3 ) <EOL> example4 = ThemedCountryTable ( qs , prefix = "<STR_LIT>" ) <EOL> RequestConfig ( request , paginate = { "<STR_LIT>" : <NUM_LIT:3> } ) . configure ( example4 ) <EOL> example5 = ThemedCountryTable ( qs , prefix = "<STR_LIT>" ) <EOL> example5 . template = "<STR_LIT>" <EOL> RequestConfig ( request , paginate = { "<STR_LIT>" : <NUM_LIT:3> } ) . configure ( example5 ) <EOL> return render ( request , '<STR_LIT>' , { <EOL> '<STR_LIT>' : example1 , <EOL> '<STR_LIT>' : example2 , <EOL> '<STR_LIT>' : example3 , <EOL> '<STR_LIT>' : example4 , <EOL> '<STR_LIT>' : example5 , <EOL> } ) <EOL> def bootstrap ( request ) : <EOL> '''<STR_LIT>''' <EOL> if Person . objects . all ( ) . count ( ) < <NUM_LIT:50> : <EOL> countries = list ( Country . objects . all ( ) ) + [ None ] <EOL> Person . objects . bulk_create ( [ <EOL> Person ( name = words ( <NUM_LIT:3> , common = False ) , country = choice ( countries ) ) <EOL> for i in range ( <NUM_LIT:50> ) <EOL> ] ) <EOL> table = BootstrapTable ( Person . objects . all ( ) ) <EOL> RequestConfig ( request , paginate = { "<STR_LIT>" : <NUM_LIT:10> } ) . configure ( table ) <EOL> return render ( request , '<STR_LIT>' , { <EOL> '<STR_LIT>' : table <EOL> } ) <EOL> class ClassBased ( SingleTableView ) : <EOL> table_class = ThemedCountryTable <EOL> queryset = Country . objects . all ( ) <EOL> template_name = "<STR_LIT>" <EOL> class_based = ClassBased . as_view ( ) <EOL> def tutorial ( request ) : <EOL> return render ( request , "<STR_LIT>" , { "<STR_LIT>" : Person . objects . all ( ) } ) </s>
