SlideShare a Scribd company logo
Inside PyMongo

Mike Dirolf (@mdirolf)
PyMongo
(see also: MongoKit, Ming, MongoEngine, etc.)
API Basics
>>> from pymongo import Connection

>>> db = Connection().test_db

>>> db.test.insert({"x": 1})
ObjectId('4bdafd07e6fb1b351e000000')

>>> db.test.find_one()
{u'x': 1, u'_id':
ObjectId('4bdafd07e6fb1b351e000000')
}
In 1.6
GridFS (setup)

>>>   from pymongo import Connection
>>>   import gridfs
>>>
>>>   db = Connection().gridfs_example
>>>   fs = gridfs.GridFS(db)
GridFS (before)
>>>   f = fs.open("hello.txt", "w")
>>>   f.write("hello ")
>>>   f.write("world")
>>>   f.close()

>>> g = fs.open("hello.txt")
>>> g.read()
'hello world'
>>> g.close()
GridFS (after)

>>> fs.put(“hello world”)

>>> file_id = fs.put("hello world")
>>> fs.get(file_id).read()
'hello world'
GridFS (after)
>>> myfile = fs.new_file(location=[-74, 40.74])
>>> myfile.write("hello ")
>>> myfile.write("world,")
>>> myfile.writelines([" and have a ", "good day!"])
>>> myfile.close()
>>> out = fs.get(myfile._id)
>>> out.read()
'hello world, and have a good day!'
>>> out.location
[-74, 40.740000000000002]
Commands (before)

>>> db.command({“buildinfo”: 1})

>>> db.command({“collstats”: collection})

>>> db.command(SON([(“filemd5”, object_id),
                    (“root”, file_root)]))
Commands (after)

>>> db.command(“buildinfo”)

>>> db.command(“collstats”, collection)

>>> db.command(“filemd5”, object_id,
               root=file_root)
PyMongo + mod_wsgi
Stored JS (1.5)

>>> db.system_js.add1 = "function (x) { return x + 1; }"

>>> db.system_js.add1(5)
6.0

>>> del db.system_js.add1




       http://dirolf.com/2010/04/05/stored-javascript-in-mongodb-and-pymongo.html
In 1.6+
$slice and
           Field Negation

>>> db.test.find(fields=[“foo”])

>>> db.test.find(fields={“foo”: 0})

>>> db.test.find(fields={“foo”: {“$slice”: -2}})
y2038
Aware Datetimes
max_scan


>>> db.test.find({“x”: 1}).max_scan(25)
as_class
>>> c = Connection()
>>> c.db.test.save({"x": 1})
ObjectId('4bf6a71be6fb1b4bce000000')

>>> c.db.test.find_one()
{u'x': 1, u'_id': ObjectId('4bf6a71be6fb1b4bce000000')}

>>> c.db.test.find_one(as_class=SON)
SON([(u'_id', ObjectId('4bf6a71be6fb1b4bce000000')), (u'x', 1)])

>>> c.document_class=SON
>>> c.db.test.find_one()
SON([(u'_id', ObjectId('4bf6a71be6fb1b4bce000000')), (u'x', 1)])
Get involved!
http://github.com/mongodb/mongo-python-driver
?
Yes...
 ...but also sometimes no
Similar to                            +
• A lot of Django doesn’t depend on django.db:
 • URL dispatch, templates, I18N, caching, etc.
• Some things do:
 • Models
 • Auth
 • Sessions
 • Admin
settings.py
DATABASE_ENGINE = ''
DATABASE_NAME = ''
DATABASE_USER = ''
DATABASE_PASSWORD = ''
DATABASE_HOST = ''
DATABASE_PORT = ''

MIDDLEWARE_CLASSES = (
  'django.middleware.common.CommonMiddleware',
# 'django.contrib.sessions.middleware.SessionMiddleware',
# 'django.contrib.auth.middleware.AuthenticationMiddleware',
)

INSTALLED_APPS = (
# 'django.contrib.auth',
  'django.contrib.contenttypes',
# 'django.contrib.sessions',
  'django.contrib.sites',
)
Representing a Poll

{'question': 'Do MongoDB + Django <3 each other?',
 'pub_date': datetime.datetime(2010, 1, 21),
 'choices': [{'votes': 35, 'choice': 'Yes!'},
         {'votes': 2, 'choice': 'No...'}]}
models.py (PyMongo)
def save_poll(question):
  return db.polls.insert({"question": question,
                  "pub_date": datetime.utcnow()})

def all_polls():
  return db.polls.find()

def add_choice(poll_id, choice):
  db.polls.update({"_id": poll_id},
            {"$push": {"choices": {"choice": choice,
                            "votes": 0}}})

def add_vote(poll_id, choice):
  db.polls.update({"_id": poll_id},
            {"$inc": {"choices.%d.votes" % choice: 1}})
                                              http://api.mongodb.org/python
models.py (MongoKit)

class Poll(mongokit.Document):
   structure = {"question": str,
            "pub_date": datetime,
            "choices": [{"choice": str,
                    "votes": int}]}
   required_fields = ["question"]
   default_values = {"pub_date": datetime.utcnow}




                              http://bytebucket.org/namlook/mongokit
models.py (Ming)
class Poll(ming.Document):

  class __mongometa__:
     session = session
     name = "polls"

  _id = ming.Field(ming.schema.ObjectId)
  question = ming.Field(str, required=True)
  pub_date = ming.Field(datetime.datetime,
           if_missing=datetime.datetime.utcnow)
  choices = ming.Field([{"choice": str,
                 "votes": int}])

                                http://merciless.sourceforge.net/
mango - sessions and auth


•   Full sessions support
•   mango provided User class
    •   supports is_authenticated(), set_password(), etc.




                                   http://github.com/vpulim/mango
mango - sessions and auth


SESSION_ENGINE = 'mango.session'
AUTHENTICATION_BACKENDS = ('mango.auth.Backend',)
MONGODB_HOST = 'localhost'
MONGODB_PORT = None
MONGODB_NAME = 'mydb'




                            http://github.com/vpulim/mango
What about admin?

• No great solution... yet.
• Could replace admin app like mango does
  for sessions / auth
• Or...
Supporting MongoDB
    in django.db

More Related Content

What's hot (20)

PPTX
TDD Training
Manuela Grindei
 
PPT
Spock Framework
Леонид Ставила
 
PDF
Spock Testing Framework - The Next Generation
BTI360
 
PDF
GMock framework
corehard_by
 
PPTX
report
Quickoffice Test
 
PDF
Redux for ReactJS Programmers
David Rodenas
 
PDF
Java practical(baca sem v)
mehul patel
 
PPTX
Smarter Testing With Spock
IT Weekend
 
PDF
Spock Framework
Daniel Kolman
 
PDF
ES3-2020-P3 TDD Calculator
David Rodenas
 
PPTX
Smarter Testing with Spock
Dmitry Voloshko
 
PDF
JS and patterns
David Rodenas
 
PDF
The Ring programming language version 1.6 book - Part 184 of 189
Mahmoud Samir Fayed
 
PPT
Unit testing with Spock Framework
Eugene Dvorkin
 
PDF
Spock framework
Djair Carvalho
 
PDF
Advanced Java Practical File
Soumya Behera
 
PPT
2012 JDays Bad Tests Good Tests
Tomek Kaczanowski
 
PDF
Example First / A Sane Test-Driven Approach to Programming
Jonathan Acker
 
PDF
Java Generics - by Example
Ganesh Samarthyam
 
PDF
33rd Degree 2013, Bad Tests, Good Tests
Tomek Kaczanowski
 
TDD Training
Manuela Grindei
 
Spock Testing Framework - The Next Generation
BTI360
 
GMock framework
corehard_by
 
Redux for ReactJS Programmers
David Rodenas
 
Java practical(baca sem v)
mehul patel
 
Smarter Testing With Spock
IT Weekend
 
Spock Framework
Daniel Kolman
 
ES3-2020-P3 TDD Calculator
David Rodenas
 
Smarter Testing with Spock
Dmitry Voloshko
 
JS and patterns
David Rodenas
 
The Ring programming language version 1.6 book - Part 184 of 189
Mahmoud Samir Fayed
 
Unit testing with Spock Framework
Eugene Dvorkin
 
Spock framework
Djair Carvalho
 
Advanced Java Practical File
Soumya Behera
 
2012 JDays Bad Tests Good Tests
Tomek Kaczanowski
 
Example First / A Sane Test-Driven Approach to Programming
Jonathan Acker
 
Java Generics - by Example
Ganesh Samarthyam
 
33rd Degree 2013, Bad Tests, Good Tests
Tomek Kaczanowski
 

Viewers also liked (18)

PDF
InnoDB architecture and performance optimization (Пётр Зайцев)
Ontico
 
PPTX
排队论及其应用浅析
frogd
 
PDF
Indexing
Mike Dirolf
 
PDF
Linux performance tuning & stabilization tips (mysqlconf2010)
Yoshinori Matsunobu
 
PDF
Performance Schema for MySQL troubleshooting
Sveta Smirnova
 
PDF
Mvcc (oracle, innodb, postgres)
frogd
 
PDF
Methods of Sharding MySQL
Laine Campbell
 
PDF
MongoDB WiredTiger Internals
Norberto Leite
 
PDF
淺入淺出 MySQL & PostgreSQL
Yi-Feng Tzeng
 
KEY
MongoDB: How it Works
Mike Dirolf
 
PDF
The InnoDB Storage Engine for MySQL
Morgan Tocker
 
PDF
MongodB Internals
Norberto Leite
 
PDF
MyRocks Deep Dive
Yoshinori Matsunobu
 
PDF
MySQL Performance Tuning. Part 1: MySQL Configuration (includes MySQL 5.7)
Aurimas Mikalauskas
 
PPT
MySQL Atchitecture and Concepts
Tuyen Vuong
 
PDF
MySQL Sharding: Tools and Best Practices for Horizontal Scaling
Mats Kindahl
 
PDF
SSD Deployment Strategies for MySQL
Yoshinori Matsunobu
 
PDF
Inside MongoDB: the Internals of an Open-Source Database
Mike Dirolf
 
InnoDB architecture and performance optimization (Пётр Зайцев)
Ontico
 
排队论及其应用浅析
frogd
 
Indexing
Mike Dirolf
 
Linux performance tuning & stabilization tips (mysqlconf2010)
Yoshinori Matsunobu
 
Performance Schema for MySQL troubleshooting
Sveta Smirnova
 
Mvcc (oracle, innodb, postgres)
frogd
 
Methods of Sharding MySQL
Laine Campbell
 
MongoDB WiredTiger Internals
Norberto Leite
 
淺入淺出 MySQL & PostgreSQL
Yi-Feng Tzeng
 
MongoDB: How it Works
Mike Dirolf
 
The InnoDB Storage Engine for MySQL
Morgan Tocker
 
MongodB Internals
Norberto Leite
 
MyRocks Deep Dive
Yoshinori Matsunobu
 
MySQL Performance Tuning. Part 1: MySQL Configuration (includes MySQL 5.7)
Aurimas Mikalauskas
 
MySQL Atchitecture and Concepts
Tuyen Vuong
 
MySQL Sharding: Tools and Best Practices for Horizontal Scaling
Mats Kindahl
 
SSD Deployment Strategies for MySQL
Yoshinori Matsunobu
 
Inside MongoDB: the Internals of an Open-Source Database
Mike Dirolf
 
Ad

Similar to Inside PyMongo - MongoNYC (20)

KEY
Python Development (MongoSF)
Mike Dirolf
 
KEY
MongoDB hearts Django? (Django NYC)
Mike Dirolf
 
KEY
MongoDB at ZPUGDC
Mike Dirolf
 
PPTX
Rapid and Scalable Development with MongoDB, PyMongo, and Ming
Rick Copeland
 
PPT
Rapid and Scalable Development with MongoDB, PyMongo, and Ming
Rick Copeland
 
KEY
Round pegs and square holes
Daniel Greenfeld
 
PDF
REST Web API with MongoDB
MongoDB
 
KEY
MongoDB NYC Python
Mike Dirolf
 
PDF
Python and MongoDB
Norberto Leite
 
PPT
Allura - an Open Source MongoDB Based Document Oriented SourceForge
Rick Copeland
 
ODP
Python and MongoDB
Christiano Anderson
 
PPTX
Dev Jumpstart: Build Your First App with MongoDB
MongoDB
 
PDF
MongoDB World 2016: From the Polls to the Trolls: Seeing What the World Think...
MongoDB
 
KEY
MongoDB Command Line Tools
Rainforest QA
 
KEY
MongoDB EuroPython 2009
Mike Dirolf
 
PDF
MongoDB and Python
Norberto Leite
 
KEY
MongoDB at RuPy
Mike Dirolf
 
PDF
Django mongodb -djangoday_
WEBdeBS
 
PDF
From mysql to MongoDB(MongoDB2011北京交流会)
Night Sailer
 
PDF
MongoDB: a gentle, friendly overview
Antonio Pintus
 
Python Development (MongoSF)
Mike Dirolf
 
MongoDB hearts Django? (Django NYC)
Mike Dirolf
 
MongoDB at ZPUGDC
Mike Dirolf
 
Rapid and Scalable Development with MongoDB, PyMongo, and Ming
Rick Copeland
 
Rapid and Scalable Development with MongoDB, PyMongo, and Ming
Rick Copeland
 
Round pegs and square holes
Daniel Greenfeld
 
REST Web API with MongoDB
MongoDB
 
MongoDB NYC Python
Mike Dirolf
 
Python and MongoDB
Norberto Leite
 
Allura - an Open Source MongoDB Based Document Oriented SourceForge
Rick Copeland
 
Python and MongoDB
Christiano Anderson
 
Dev Jumpstart: Build Your First App with MongoDB
MongoDB
 
MongoDB World 2016: From the Polls to the Trolls: Seeing What the World Think...
MongoDB
 
MongoDB Command Line Tools
Rainforest QA
 
MongoDB EuroPython 2009
Mike Dirolf
 
MongoDB and Python
Norberto Leite
 
MongoDB at RuPy
Mike Dirolf
 
Django mongodb -djangoday_
WEBdeBS
 
From mysql to MongoDB(MongoDB2011北京交流会)
Night Sailer
 
MongoDB: a gentle, friendly overview
Antonio Pintus
 
Ad

More from Mike Dirolf (11)

PDF
FrozenRails Training
Mike Dirolf
 
PDF
MongoDB at FrozenRails
Mike Dirolf
 
PDF
Introduction to MongoDB
Mike Dirolf
 
KEY
MongoDB at CodeMash 2.0.1.0
Mike Dirolf
 
PDF
MongoDB at RubyConf
Mike Dirolf
 
KEY
MongoDB at RubyEnRails 2009
Mike Dirolf
 
KEY
MongoDB Strange Loop 2009
Mike Dirolf
 
KEY
MongoDB Hadoop DC
Mike Dirolf
 
KEY
MongoDB London PHP
Mike Dirolf
 
KEY
MongoDB SF Python
Mike Dirolf
 
KEY
MongoDB SF Ruby
Mike Dirolf
 
FrozenRails Training
Mike Dirolf
 
MongoDB at FrozenRails
Mike Dirolf
 
Introduction to MongoDB
Mike Dirolf
 
MongoDB at CodeMash 2.0.1.0
Mike Dirolf
 
MongoDB at RubyConf
Mike Dirolf
 
MongoDB at RubyEnRails 2009
Mike Dirolf
 
MongoDB Strange Loop 2009
Mike Dirolf
 
MongoDB Hadoop DC
Mike Dirolf
 
MongoDB London PHP
Mike Dirolf
 
MongoDB SF Python
Mike Dirolf
 
MongoDB SF Ruby
Mike Dirolf
 

Recently uploaded (20)

PDF
NLJUG Speaker academy 2025 - first session
Bert Jan Schrijver
 
PDF
Survival Models: Proper Scoring Rule and Stochastic Optimization with Competi...
Paris Women in Machine Learning and Data Science
 
PPTX
Agentforce World Tour Toronto '25 - Supercharge MuleSoft Development with Mod...
Alexandra N. Martinez
 
PPTX
Role_of_Artificial_Intelligence_in_Livestock_Extension_Services.pptx
DrRajdeepMadavi
 
PPTX
Mastering ODC + Okta Configuration - Chennai OSUG
HathiMaryA
 
DOCX
Python coding for beginners !! Start now!#
Rajni Bhardwaj Grover
 
DOCX
Cryptography Quiz: test your knowledge of this important security concept.
Rajni Bhardwaj Grover
 
PDF
[GDGoC FPTU] Spring 2025 Summary Slidess
minhtrietgect
 
PDF
Next Generation AI: Anticipatory Intelligence, Forecasting Inflection Points ...
dleka294658677
 
PPTX
MuleSoft MCP Support (Model Context Protocol) and Use Case Demo
shyamraj55
 
PDF
Book industry state of the nation 2025 - Tech Forum 2025
BookNet Canada
 
PDF
ICONIQ State of AI Report 2025 - The Builder's Playbook
Razin Mustafiz
 
PDF
Bitkom eIDAS Summit | European Business Wallet: Use Cases, Macroeconomics, an...
Carsten Stoecker
 
PDF
Linux schedulers for fun and profit with SchedKit
Alessio Biancalana
 
PDF
Go Concurrency Real-World Patterns, Pitfalls, and Playground Battles.pdf
Emily Achieng
 
PDF
99 Bottles of Trust on the Wall — Operational Principles for Trust in Cyber C...
treyka
 
PDF
Automating Feature Enrichment and Station Creation in Natural Gas Utility Net...
Safe Software
 
PPTX
The Project Compass - GDG on Campus MSIT
dscmsitkol
 
PDF
Home Cleaning App Development Services.pdf
V3cube
 
PDF
Modern Decentralized Application Architectures.pdf
Kalema Edgar
 
NLJUG Speaker academy 2025 - first session
Bert Jan Schrijver
 
Survival Models: Proper Scoring Rule and Stochastic Optimization with Competi...
Paris Women in Machine Learning and Data Science
 
Agentforce World Tour Toronto '25 - Supercharge MuleSoft Development with Mod...
Alexandra N. Martinez
 
Role_of_Artificial_Intelligence_in_Livestock_Extension_Services.pptx
DrRajdeepMadavi
 
Mastering ODC + Okta Configuration - Chennai OSUG
HathiMaryA
 
Python coding for beginners !! Start now!#
Rajni Bhardwaj Grover
 
Cryptography Quiz: test your knowledge of this important security concept.
Rajni Bhardwaj Grover
 
[GDGoC FPTU] Spring 2025 Summary Slidess
minhtrietgect
 
Next Generation AI: Anticipatory Intelligence, Forecasting Inflection Points ...
dleka294658677
 
MuleSoft MCP Support (Model Context Protocol) and Use Case Demo
shyamraj55
 
Book industry state of the nation 2025 - Tech Forum 2025
BookNet Canada
 
ICONIQ State of AI Report 2025 - The Builder's Playbook
Razin Mustafiz
 
Bitkom eIDAS Summit | European Business Wallet: Use Cases, Macroeconomics, an...
Carsten Stoecker
 
Linux schedulers for fun and profit with SchedKit
Alessio Biancalana
 
Go Concurrency Real-World Patterns, Pitfalls, and Playground Battles.pdf
Emily Achieng
 
99 Bottles of Trust on the Wall — Operational Principles for Trust in Cyber C...
treyka
 
Automating Feature Enrichment and Station Creation in Natural Gas Utility Net...
Safe Software
 
The Project Compass - GDG on Campus MSIT
dscmsitkol
 
Home Cleaning App Development Services.pdf
V3cube
 
Modern Decentralized Application Architectures.pdf
Kalema Edgar
 

Inside PyMongo - MongoNYC

  • 2. PyMongo (see also: MongoKit, Ming, MongoEngine, etc.)
  • 3. API Basics >>> from pymongo import Connection >>> db = Connection().test_db >>> db.test.insert({"x": 1}) ObjectId('4bdafd07e6fb1b351e000000') >>> db.test.find_one() {u'x': 1, u'_id': ObjectId('4bdafd07e6fb1b351e000000') }
  • 5. GridFS (setup) >>> from pymongo import Connection >>> import gridfs >>> >>> db = Connection().gridfs_example >>> fs = gridfs.GridFS(db)
  • 6. GridFS (before) >>> f = fs.open("hello.txt", "w") >>> f.write("hello ") >>> f.write("world") >>> f.close() >>> g = fs.open("hello.txt") >>> g.read() 'hello world' >>> g.close()
  • 7. GridFS (after) >>> fs.put(“hello world”) >>> file_id = fs.put("hello world") >>> fs.get(file_id).read() 'hello world'
  • 8. GridFS (after) >>> myfile = fs.new_file(location=[-74, 40.74]) >>> myfile.write("hello ") >>> myfile.write("world,") >>> myfile.writelines([" and have a ", "good day!"]) >>> myfile.close() >>> out = fs.get(myfile._id) >>> out.read() 'hello world, and have a good day!' >>> out.location [-74, 40.740000000000002]
  • 9. Commands (before) >>> db.command({“buildinfo”: 1}) >>> db.command({“collstats”: collection}) >>> db.command(SON([(“filemd5”, object_id), (“root”, file_root)]))
  • 10. Commands (after) >>> db.command(“buildinfo”) >>> db.command(“collstats”, collection) >>> db.command(“filemd5”, object_id, root=file_root)
  • 12. Stored JS (1.5) >>> db.system_js.add1 = "function (x) { return x + 1; }" >>> db.system_js.add1(5) 6.0 >>> del db.system_js.add1 http://dirolf.com/2010/04/05/stored-javascript-in-mongodb-and-pymongo.html
  • 14. $slice and Field Negation >>> db.test.find(fields=[“foo”]) >>> db.test.find(fields={“foo”: 0}) >>> db.test.find(fields={“foo”: {“$slice”: -2}})
  • 15. y2038
  • 18. as_class >>> c = Connection() >>> c.db.test.save({"x": 1}) ObjectId('4bf6a71be6fb1b4bce000000') >>> c.db.test.find_one() {u'x': 1, u'_id': ObjectId('4bf6a71be6fb1b4bce000000')} >>> c.db.test.find_one(as_class=SON) SON([(u'_id', ObjectId('4bf6a71be6fb1b4bce000000')), (u'x', 1)]) >>> c.document_class=SON >>> c.db.test.find_one() SON([(u'_id', ObjectId('4bf6a71be6fb1b4bce000000')), (u'x', 1)])
  • 20. ?
  • 21. Yes... ...but also sometimes no
  • 22. Similar to + • A lot of Django doesn’t depend on django.db: • URL dispatch, templates, I18N, caching, etc. • Some things do: • Models • Auth • Sessions • Admin
  • 23. settings.py DATABASE_ENGINE = '' DATABASE_NAME = '' DATABASE_USER = '' DATABASE_PASSWORD = '' DATABASE_HOST = '' DATABASE_PORT = '' MIDDLEWARE_CLASSES = ( 'django.middleware.common.CommonMiddleware', # 'django.contrib.sessions.middleware.SessionMiddleware', # 'django.contrib.auth.middleware.AuthenticationMiddleware', ) INSTALLED_APPS = ( # 'django.contrib.auth', 'django.contrib.contenttypes', # 'django.contrib.sessions', 'django.contrib.sites', )
  • 24. Representing a Poll {'question': 'Do MongoDB + Django <3 each other?', 'pub_date': datetime.datetime(2010, 1, 21), 'choices': [{'votes': 35, 'choice': 'Yes!'}, {'votes': 2, 'choice': 'No...'}]}
  • 25. models.py (PyMongo) def save_poll(question): return db.polls.insert({"question": question, "pub_date": datetime.utcnow()}) def all_polls(): return db.polls.find() def add_choice(poll_id, choice): db.polls.update({"_id": poll_id}, {"$push": {"choices": {"choice": choice, "votes": 0}}}) def add_vote(poll_id, choice): db.polls.update({"_id": poll_id}, {"$inc": {"choices.%d.votes" % choice: 1}}) http://api.mongodb.org/python
  • 26. models.py (MongoKit) class Poll(mongokit.Document): structure = {"question": str, "pub_date": datetime, "choices": [{"choice": str, "votes": int}]} required_fields = ["question"] default_values = {"pub_date": datetime.utcnow} http://bytebucket.org/namlook/mongokit
  • 27. models.py (Ming) class Poll(ming.Document): class __mongometa__: session = session name = "polls" _id = ming.Field(ming.schema.ObjectId) question = ming.Field(str, required=True) pub_date = ming.Field(datetime.datetime, if_missing=datetime.datetime.utcnow) choices = ming.Field([{"choice": str, "votes": int}]) http://merciless.sourceforge.net/
  • 28. mango - sessions and auth • Full sessions support • mango provided User class • supports is_authenticated(), set_password(), etc. http://github.com/vpulim/mango
  • 29. mango - sessions and auth SESSION_ENGINE = 'mango.session' AUTHENTICATION_BACKENDS = ('mango.auth.Backend',) MONGODB_HOST = 'localhost' MONGODB_PORT = None MONGODB_NAME = 'mydb' http://github.com/vpulim/mango
  • 30. What about admin? • No great solution... yet. • Could replace admin app like mango does for sessions / auth • Or...
  • 31. Supporting MongoDB in django.db