How to use the dt.models.Record.objects function in dt

To help you get started, we’ve selected a few dt examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github embali / windseed / djangotest / dt / views.py View on Github external
def index(request):
    page = int(request.GET.get('page', 1))

    records = Record.objects.filter(active=True).order_by('name')
    pages = Paginator(records, 48)

    '''
    records = pages.page(page).object_list
    '''
    records_pages = RecordPage.objects\
        .filter(page=page)\
        .select_related('record')

    return render(
        request,
        'records.html',
        dict(
            records=[record_page.record for record_page in records_pages],
            prev_page=pages.page(page).previous_page_number()
            if pages.page(page).has_previous() else None,