MongoEngine - An example to get started

To get started with mongoengine for manipulating mongodb using python, you can try this super basic example: 1. Install mongodb : http://docs.mongodb.org/manual/installation/ 2. Create an isolated python environment with virtualenv : $ virtualenv /home/.venv/example $ source /home/.venv/example/bin/activate 3. Install mongoengine inside the virtual environment: (example) trinh@trinh-pc$ pip install mongoengine 4. Run python command to enter the console >> connect to a db >> define some models >> and create instances using mongoengine api: $ python >>> from mongoengine import * >>> connect('test') MongoClient('localhost', 27017) >>> class User(Document): . . . name = StringField() . . . >>> class Post(Document): . . . content = StringField() . . . author = ReferenceField(User) >>> my_user = User(name="Trinh Ng...