Skip to content

Instantly share code, notes, and snippets.

@skyl skyl/gist:423540
Created Jun 3, 2010

What would you like to do?
from django.db import models
from mymongo.models import Mongo
class M(models.Model):
mongo = Mongo()
>>> type(M.mongo)
<class 'mymongo.models.Collection'>
>>> M.mongo._collection
Collection(Database(Connection('localhost', 27017), u'app_label'), u'module_name')
>>> m = M.objects.get(...)
>>> type(m.mongo)
<class 'mymongo.models.Document'>
>>> m.mongo # acts as much like a dict as possible
{'_id': 4}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.