Skip to main content

Do Django generic foreign key lookups in one query

Project description

Django Fast Generic Foreign Keys

Travis

Travis

Overview

Generic foreign keys are incredibly powerful but can’t be prefetched, leading to a large number of SQL queries when accessing a generic foreign key field while iterating over a queryset. This app provides a function that reduces the number of SQL queries to 1 + (number of content types included in the set of generic foreign keys).

Installation

  1. Install or add django-fast-gfk to your Python path.

Usage

The fetch function returns a generator with the generic foreign key prefetched. Parameter field is the name of the generic foreign key.:

from fast_gfk import fetch

fetch(Bar.objects.all(), field="target"))

Authors

  • Hedley Roos

Changelog

0.1

  1. Initial release.

Project details


Release history Release notifications | RSS feed

This version

0.1

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for django-fast-gfk, version 0.1
Filename, size File type Python version Upload date Hashes
Filename, size django_fast_gfk-0.1-py2.7.egg (9.3 kB) File type Egg Python version 2.7 Upload date Hashes View
Filename, size django-fast-gfk-0.1.tar.gz (4.8 kB) File type Source Python version None Upload date Hashes View

Supported by

Pingdom Pingdom Monitoring Google Google Object Storage and Download Analytics Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page