Django Mongoengine RQL
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.
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:
distinctsetting is not supported for filters- annotations are not supported, as well
Development
- Python 3.10+
- Install dependencies
pip install poetry && poetry install - We use
isortlibrary to order and format our imports, andblack- to format the code. We check it usingflake8-isortandflake8-blacklibraries (automatically onflake8run).
For convenience you may rundocker compose run formatto format the code.
Testing
- Python 3.10+
- 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 resultscoverage.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)
| File | Size | Uploaded | |
|---|---|---|---|
| django_mongoengine_rql-1.0.0.tar.gz | 7.9 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| 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
|