Created
June 3, 2010 06:06
-
-
Save skyl/423540 to your computer and use it in GitHub Desktop.
djongobjomposition
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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