Skip to content

Instantly share code, notes, and snippets.

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

Embed
What would you like to do?
djongobjomposition
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(...)
>>> m.pk
4
>>> 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.