Skip to main content

Django Mongoengine RQL

pyversions PyPi Status PyPI status PyPI Downloads Quality Gate Status Coverage

Introduction

RQL (Resource query language) is designed for modern application development. It is built for the web, ready for NoSQL, and highly extensible with simple syntax. This is a query language for fast and convenient database interaction. RQL was designed for use in URLs to request object-style data structures.

This library is a Mongoengine-specific implementation of RQL filtering.

RQL Reference

Django RQL

Mongoengine

Install

Django Mongoengine RQL can be installed from pypi.org using pip:

$ pip install django-mongoengine-rql

Documentation

This library is fully based on Django RQL, so there are no specific docs for it. Full documentation for Django-RQL is available at https://django-rql.readthedocs.org.

Example

# filters.py
from dj_mongoengine_rql.filter_cls import MongoengineRQLFilterClass
from py_rql.constants import FilterLookups
from your_docs import Document

class DocFilters(MongoengineRQLFilterClass):
    MODEL = Document
    SELECT = True
    FILTERS = (
        'filter1',
        {
            'filter': 'filter2',
            'source': 'related_doc__doc_field',
        },
        {
            'namespace': 'ns1',
            'filters': ('ns1f',),
        },
        {
            'filter': 'filter3',
            'lookups': {FilterLookups.EQ, FilterLookups.IN},
        },
    )


# views.py
from dj_rql.drf.backend import RQLFilterBackend
from dj_rql.drf.paginations import RQLContentRangeLimitOffsetPagination
from rest_framework import mixins
from rest_framework.viewsets import GenericViewSet

class DRFViewSet(mixins.ListModelMixin, GenericViewSet):
    queryset = Document.objects.all()
    rql_filter_class = DocFilters
    pagination_class = RQLContentRangeLimitOffsetPagination
    filter_backends = (RQLFilterBackend,)

Notes

Due to implementation and Mongo engine features there may be some limitations in filtering, for example:

  • distinct setting is not supported for filters
  • annotations are not supported, as well

Development

  1. Python 3.10+
  2. Install dependencies pip install poetry && poetry install
  3. We use isort library to order and format our imports, and black - to format the code. We check it using flake8-isort and flake8-black libraries (automatically on flake8 run).
    For convenience you may run docker compose run format to format the code.

Testing

  1. Python 3.10+
  2. Install dependencies pip install poetry && poetry install

Check code style: poetry run flake8 Run tests: poetry run pytest Run integration tests: docker compose run app_test

Tests reports are generated in tests/reports.

  • out.xml - JUnit test results
  • coverage.xml - Coverage xml results

To generate HTML coverage reports use: --cov-report html:tests/reports/cov_html

License

Django Mongoengine RQL is released under the Apache License Version 2.0.

Metadata

Release files for django-mongoengine-rql 1.0.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for django-mongoengine-rql 1.0.0
File Size Uploaded
django_mongoengine_rql-1.0.0.tar.gz 7.9 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for django-mongoengine-rql 1.0.0
File Interpreter ABI Platform
django_mongoengine_rql-1.0.0-py3-none-any.whl Python 3 none any Details

Total release size: 17.0 kB

Release files / django_mongoengine_rql-1.0.0.tar.gz

Download URL django_mongoengine_rql-1.0.0.tar.gz
Size 7.9 kB
Tags Source
SHA-256 checksum
How to use checksums
c51a5832692791aed43c89bce7e06f1aa7bb47fbd88bffa67eb22a239cb0b99f
BLAKE2b-256 checksum
How to use checksums
750a5d7bf13b6ccaf9de71a37bfee170f597da0fa2f3f1d72de68b1d07a6e444
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/2.4.3 CPython/3.10.21 Linux/6.17.0-1022-azure

Release files / django_mongoengine_rql-1.0.0-py3-none-any.whl

Download URL django_mongoengine_rql-1.0.0-py3-none-any.whl
Size 9.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
c3e94bba379b8e56fa4bedb6f643341ad8a0fe7d5d5f402eedf621ba44bf4cfb
BLAKE2b-256 checksum
How to use checksums
e644384c67eda5e8f47845b66c93d84ce2e47fedefed9c9729b7fb5021ba23e1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/2.4.3 CPython/3.10.21 Linux/6.17.0-1022-azure

Release history Release notifications | RSS feed

This release

1.0.0 This release

2 release files

0.2.2

2 release files

0.2.1

2 release files

0.2.0

2 release files

0.1.3

2 release files

0.1.2

2 release files

0.1.1

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page