Qval supports configuration via config files and environmental variables. If DJANGO_SETTINGS_MODULE or SETTINGS_MODULE are defined, the specified config module will be used. Otherwise, all lookups would be done in os.environ.

Supported variables:

  • QVAL_MAKE_REQUEST_WRAPPER = myapp.myfile.my_func. Customizes behaviour of the make_request() function, which is applied to all incoming requests, then the result is passed to qval.qval.QueryParamValidator. The provided function must accept request and return object that supports request interface (see DummyRequest).
    For example, the following code adds print to each make_request() call:
    # app/
    def my_wrapper(f):
        def wrapper(request):
            print(f"Received new request: {request}")
            return f(request)
        return wrapper
    Also you need to execute export QVAL_MAKE_REQUEST_WRAPPER=app.utils.my_wrapper in your console or to add it to the config file.
  • QVAL_REQUEST_CLASS = @qval() will use it to determine which argument is a request. If you have a custom request class that implements DummyRequest() interface, provide it with this variable.
  • QVAL_LOGGERS = [mylogger.factory, ...] | mylogger.factory. List of paths or path to a factory callable. Specified callable must return object with Logger interface. See section Logging) for more info.


Qval uses a global log object acting as singleton when reporting errors. By default, logging.getLogger() function is used as a factory on each call. You can provide your own factory (see Settings) or disable the logging. Example error message:

An error occurred during the validation or inside of the context: exc `<class 'OverflowError'>` ((34, 'Numerical result out of range')).
| Parameters: <QueryDict: {'a': ['2.2324'], 'b': ['30000000']}>
| Body      : b''
| Exception:
Traceback (most recent call last):
  File "<path>/qval/", line 338, in inner
    return f(*args, params, **kwargs)
  File "<path>/examples/django-example/app/", line 46, in pow_view
    return JsonResponse({"answer": params.a ** params.b})
OverflowError: (34, 'Numerical result out of range')
Internal Server Error: /api/pow
[19/Nov/2018 07:03:15] "GET /api/pow?a=2.2324&b=30000000 HTTP/1.1" 500 102

Import the log object from qval.utils and configure as you need:

from qval import log
# For instance, disable logging: