Before we get into the technical details of the implementations described in this chapter, it's necessary to provide an overall view of what we plan to achieve. Django provides an object-to-form mapping by way of its ModelForm class. However, in order to use this class we would need to create Django Models, which correspond to the entity classes we have described to this point.
The problem with using Django Models and ModelForm classes is that we end up being tied to SQL and the RDBMS way of thinking, which imposes incredible constraints on a MongoDB implementation, and in effect defeats the purpose of using MongoDB in the first place. Such an approach introduces a massive amount of overhead, with additional functionality that is never used. Instead, our proposed solution for adding data to MongoDB documents with embedded objects and arrays is to do the following:
- Create a Django form class that corresponds to each entity class.
- Move the posted data from each...