Blocks any DB query from being executed within the context.
Project description
django-query-blocker
Prevents django to perform any query within the context or decorated method
Table of Contents
Why Should I Use This?
Django ORM is great and easy to use but can easily hide some very back behaviours. Just by calling a property here and there you can cascade a chain of hundreds of queries hidden behind the easy-to-use model abstractions. This lib prevents it to happen by locking the ORM not allowing it to perform the queries by raising an exception.
How To Install
- Install with
pip install django-query-blocker
How To Use
- It can be used as a context or decorator
Context
from query_blocker import block_extra_queries
my_object = MyModel.objects.first()
print(my_object) # works fine
with block_extra_queries:
print(obj.foreign_key_obj) # will raise a NoExtraQueryException
Decorator
from query_blocker import block_extra_queries
@block_extra_queries
def my_method(obj):
print(obj.foreign_key_obj)
my_object = MyModel.objects.first()
print(my_object) # works fine
my_method(my_object) # will raise a NoExtraQueryException
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
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file django-query-blocker-0.0.1.tar.gz.
File metadata
- Download URL: django-query-blocker-0.0.1.tar.gz
- Upload date:
- Size: 3.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.9.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c9f61a0db0d03f1d204833e41409c78f5422ea82fb87325a5638d08617f6f567
|
|
| MD5 |
626161004f7302edcc30dcc4bf95e294
|
|
| BLAKE2b-256 |
0638cb25f0ec11c78a055c9e6cca8f201b5b3ee020955d90299daf934a937b45
|
File details
Details for the file django_query_blocker-0.0.1-py2.py3-none-any.whl.
File metadata
- Download URL: django_query_blocker-0.0.1-py2.py3-none-any.whl
- Upload date:
- Size: 3.7 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.9.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b12b44723876a7764ebc2439810ce40a2c516546ddfbd2fd270645d87e61dccc
|
|
| MD5 |
b3962c9418173d6aeba1984083404086
|
|
| BLAKE2b-256 |
9b7a7f1b0d5f67e0400d46180fcf215ccd935cb639e541a97aca90fccba1ebe2
|