This project, django-documentdb, is a fork of the original django-mongodb repository, which was developed and maintained by the MongoDB Python Team. The primary purpose of this fork is to enhance compatibility with AWS DocumentDB, a MongoDB-compatible database service provided by Amazon Web Services. To accommodate the differences between DocumentDB and MongoDB’s API support, specific adjustments have been implemented to ensure seamless functionality within DocumentDB.
We encourage users to provide feedback and report any issues as we continue to improve the library. You can share your thoughts, suggestions, or report problems on our GitHub Issues page
For full documentation, including installation, configuration, etc. Please see https://django-documentdb.readthedocs.io/
To install django_documentdb, use one of the following methods:
You can install django_documentdb with:
pip install django_documentdbIf you're using Poetry to manage your dependencies, you can add django_documentdb to your project with:
poetry add django_documentdbdjango-documentdb uses own QuerySet implementation (DocumentQuerySet) if you inherit your models from DocumentModel class.
from django_documentdb.models import DocumentModel
from django_documentdb import fields
from django.db import models
class TestModel(DocumentModel):
_id = fields.ObjectIdAutoField(primary_key=True)
text_value = models.CharField(max_length=100, null=True)
number_value = models.FloatField(null=True)
class Meta:
db_table = "test_db"-
QuerySet.explain()supports thecommentandverbosityoptions.Example:
QuerySet.explain(comment="...", verbosity="...")Valid values for
verbosityare"queryPlanner"(default),"executionStats", and"allPlansExecution". -
DocumentQuerySet.index_hint(index_name)- allows to specify index hint for query.
-
The following
QuerySetmethods aren't supported:bulk_update()dates()datetimes()distinct()extra()prefetch_related()
-
QuerySet.delete()andupdate()do not support queries that span multiple collections. -
DateTimeFielddoesn't support microsecond precision, and correspondingly,DurationFieldstores milliseconds rather than microseconds. -
The following database functions aren't supported:
ChrExtractQuarterMD5NowOrdPadRepeatReverseRightSHA1,SHA224,SHA256,SHA384,SHA512SignTruncDateTruncTime
-
The
tzinfoparameter of theTruncdatabase functions doesn't work properly because MongoDB converts the result back to UTC. -
When querying
JSONField:- There is no way to distinguish between a JSON "null" (represented by
Value(None, JSONField())) and a SQL null (queried using theisnulllookup). Both of these queries return both of these nulls. - Some queries with
Qobjects, e.g.Q(value__foo="bar"), don't work properly, particularly withQuerySet.exclude(). - Filtering for a
Nonekey, e.g.QuerySet.filter(value__j=None)incorrectly returns objects where the key doesn't exist. - You can study the skipped tests in
DatabaseFeatures.django_test_skipsfor more details on known issues.
- There is no way to distinguish between a JSON "null" (represented by
-
Due to the lack of ability to introspect MongoDB collection schema,
migrate --fake-initialisn't supported.
This project, django-documentdb, is a fork of the original django-mongodb library, which aimed to integrate MongoDB with Django. The fork was created to enhance compatibility with AWS DocumentDB, addressing the limitations of its API support while maintaining the core functionalities of the original library. We appreciate the work of the MongoDB Python Team and aim to build upon their foundation to better serve users needing DocumentDB integration.