Metadata-Version: 2.1
Name: django-query-blocker
Version: 0.0.1
Summary: Blocks any DB query from being executed within the context.
Home-page: https://github.com/nano-labs/django-query-blocker
Download-URL: https://github.com/nano-labs/django-query-blocker/archive/0.0.1.zip
Author: Fabio Pachelli Pacheco
Author-email: nanook.labs@gmail.com
License: MIT
Keywords: django query block debug
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Developers
Classifier: Topic :: Software Development :: Build Tools
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3.6
Description-Content-Type: text/markdown
License-File: LICENSE

# django-query-blocker
Prevents django to perform any query within the context or decorated method

## Table of Contents
1. [Why Should I Use This?](#why-should-i-use-this?)
2. [How To Install](#how-to-install)
3. [How To Use](#how-to-use)
    1. [Context](#context)
    2. [Decorator](#decorator)

## 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

```python
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

```python
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
```
