Do Django generic foreign key lookups in one query
Project description
Django Fast Generic Foreign Keys
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
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"))
Changelog
0.1
Initial release.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file django-fast-gfk-0.1.tar.gz
.
File metadata
- Download URL: django-fast-gfk-0.1.tar.gz
- Upload date:
- Size: 4.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 02bb720890527738d4f97950f8cd5196d8bc6e2fb3b7a99bf80e039998bba3a0 |
|
MD5 | 525b037ab660c7c7012c42bc0df0f3f5 |
|
BLAKE2b-256 | 1c504d26a1b876010ffef95396aa2a67dc26d7a0add895f06769c84f3c057c7a |
File details
Details for the file django_fast_gfk-0.1-py2.7.egg
.
File metadata
- Download URL: django_fast_gfk-0.1-py2.7.egg
- Upload date:
- Size: 9.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | fec7f550170c8923fa1a779ddfa3fbe1b058a9dce066bc0d668fabdc21902ff3 |
|
MD5 | 4bd36bd6b792fb66ba32627dcc23ecbc |
|
BLAKE2b-256 | c0038fd103706b416981e3db0e1f5e2c551572897bdc933726bc471203fe21f3 |