Django App Hosting for MongoDB and SQL Databases

Simplify Query Creation

Simplify Query Creation

Writing query documents can get out of control. Djongo does the heavy lifting of creating query documents for you.

More

SQL <> No SQL

SQL <=> No SQL

Switch between MongoDB and other SQL databases. Limit the impact to your Models and business logic.

More

Security

Security

Directly saving raw JSON into the database is scary. Djongo secures and validates the JSON document before saving.

More

Support

Support

Phone, Chat and Email support. Including commercial licensing for enterprises.

More

Rapid Prototyping

Rapid Prototyping

Speed up app development and execution with schema free models. Enforce levels of schema protection with data evolution.

More

Web Interface

Web Interface

Access and modify MongoDB through the web browser.

More

Djongo

Djongo Djongo provides a unified approach to database interfacing. It is an extension to the traditional Django ORM framework. It maps python objects to MongoDB documents, a technique popularly referred to as Object Document Mapping or ODM.

Constructing queries using Djongo is much easier compared to writing lengthy Pymongo query documents. Storing raw JSON emitted by the frontend directly into the database is scary. Djongo ensures that only clean data gets through.

You no longer need to use the shell to inspect your data. By using the Admin package, you can access and modify data directly from the web browser. Djongo includes handy UI elements that help represent MongoDB documents on the browser.

Security and Integrity Checks

def script_injection(value):
  if value.find('<script>') != -1:
    raise ValidationError(_('Script injection in %(value)s'),
                            params={'value': value})

class Entry(models.Model):
  homepage = models.URLField(validators=[URLValidator,
                                         script_injection])

Djongo performs checks on data fields before they are saved to the database.

Define custom validators or use builtin validators to check the data. Validation is triggered prior to writing to the database.

Running integrity checks and field value validators ensures protect from garbage data.

Rapid Prototyping

Djongo As your data evolves you may wish to enforce a structure to it. The JSONField represents documents with no structure, and no validations.

The EmbeddedField lets you describe the structure which triggers automatic validations at the application level.

Setting enforce_schema = True in the settings.py file enables schema checks at the database level.

Query Creation

PyMongo

self.db['entry'].aggregate(
    [{
        '$match': {
          'author_id': {
            '$ne': None,
            '$exists': True
          }
        }
      },
      {
        '$lookup': {
          'from': 'author',
          'localField': 'author_id',
          'foreignField': 'id',
          'as': 'author'
        }
      },
      {
        '$unwind': '$author'
      },
      {
        '$lookup': {
          'from': 'blog',
          'localField': 'blog_id',
          'foreignField': 'id',
          'as': 'blog'
        }
      },
      {
        '$unwind': {
          'path': '$blog',
          'preserveNullAndEmptyArrays': True
        }
      },
      {
        '$addFields': {
          'blog': {
            '$ifNull': ['$blog', {
              'id': None,
              'title': None
            }]
          }
        }
      },
      {
        '$match': {
          'author.name': {
            '$eq': 'Paul'
          }
        }
      }, 
      {
        '$project': {
          'id': True,
          'blog_id': True,
          'author_id': True,
          'content': True,
          'blog.id': True,
          'blog.title': True
        }
      }]

Djongo

qs = Entry.objects.filter(author__name='Paul')\
                  .select_related('blog')

Djongo generates complex, error free, aggregation queries automatically. It takes the relatively simple query on the right and automatically generates the pymongo query document on the left.

Installation and Setup

Download and install the latest version of Djongo by running:

pip install djongo

The project directory is where all Djongo settings live. Auto generate the required files by running:

django-admin startproject mysite

You can replace mysite with a name of your choosing. Go into the root of mysite directory to find the settings.py file. Add:

  DATABASES = {
      'default': {
          'ENGINE': 'djongo',
          'NAME': 'your-db-name',
      }
  }

YOU ARE SET! Have fun!

Get Started