Django Mongoengine RQL Filtering
Project description
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 Django-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:
distinct
setting is not supported for filters- annotations are not supported, as well
Development
- Python 3.8+
- Install dependencies
pip install poetry && poetry install
- We use
isort
library to order and format our imports, andblack
- to format the code. We check it usingflake8-isort
andflake8-black
libraries (automatically onflake8
run).
For convenience you may rundocker compose run format
to format the code.
Testing
- Python 3.8+
- 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.
Project details
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
File details
Details for the file django_mongoengine_rql-0.2.2.tar.gz
.
File metadata
- Download URL: django_mongoengine_rql-0.2.2.tar.gz
- Upload date:
- Size: 7.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.5.1 CPython/3.8.17 Linux/5.15.0-1040-azure
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1f53ea201c11394178b0a49145336538139f2e4138f37d91b1d0b111ffea96ff |
|
MD5 | 6f578cd6fc2c168bd08d2e75f8f03bbf |
|
BLAKE2b-256 | cff01ec1c7b8b5174b5b9c5afa4464cfe94b9db71a43cd23c0cf5397605c6224 |
File details
Details for the file django_mongoengine_rql-0.2.2-py3-none-any.whl
.
File metadata
- Download URL: django_mongoengine_rql-0.2.2-py3-none-any.whl
- Upload date:
- Size: 8.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.5.1 CPython/3.8.17 Linux/5.15.0-1040-azure
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | b6df362eef5aa08ccd3893302f3f9199d9472c30c6896b8e6aa4a886a2acf832 |
|
MD5 | 637d9bcf63a18d64c034cede65ffa5ba |
|
BLAKE2b-256 | eef5fca722a0dc933672eff58e92bc0124fa6ea0ba54cbe720095743c4faa102 |