Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
Django
Search
flaper87
April 24, 2012
750
6
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Django
flaper87
April 24, 2012
More Decks by flaper87
See All by flaper87
Inheriting code… and I don’t mean classes
flaper87
0
300
Don't try to look smart, be smart
flaper87
0
210
Keeping up with the pace of a fast growing community without dying
flaper87
0
220
A walk to remember: Debugging a distributed system failure
flaper87
0
230
Managing requirements for a many-thousands contributors software
flaper87
0
130
Fast-forward to today's Zaqar
flaper87
0
180
Breaking Backwards Compatibility: The easy way
flaper87
1
190
A functional view to Rust
flaper87
1
160
Rust - A walk to concurrency
flaper87
3
620
Featured
See All Featured
Refactoring Trust on Your Teams (GOTO; Chicago 2020)
rmw
35
3.8k
個人開発の失敗を避けるイケてる考え方 / tips for indie hackers
panda_program
123
22k
How to Get Subject Matter Experts Bought In and Actively Contributing to SEO & PR Initiatives.
livdayseo
0
200
We Analyzed 250 Million AI Search Results: Here's What I Found
joshbly
1
1.9k
GraphQLの誤解/rethinking-graphql
sonatard
75
12k
My Coaching Mixtape
mlcsv
0
320
WCS-LA-2024
lcolladotor
0
830
From Legacy to Launchpad: Building Startup-Ready Communities
dugsong
0
330
Pawsitive SEO: Lessons from My Dog (and Many Mistakes) on Thriving as a Consultant in the Age of AI
davidcarrasco
0
240
Design and Strategy: How to Deal with People Who Don’t "Get" Design
morganepeng
133
19k
Large-scale JavaScript Application Architecture
addyosmani
515
110k
How Fast Is Fast Enough? [PerfNow 2025]
tammyeverts
3
890
Transcript
So you want to use DJANGO AND MONGODB @flaper87
THAT’S COOL, but you n d to know A COUPLE
OF THINGS DJANGO AND MONGODB
LIKE: WHAT ARE THE OPTIONS?
An object-document mapper to connect Python and MongoDB ( http://mongoengine.org
)
Another ODM that takes mongodb into the web Mongokit (
http://namlook.github.com/mongokit/ )
OR, OF COURSE
DJANGO MONGODB ENGINE (A MongoDB backend for Django)
DJANGO-NONREL A good and up to date Django fork that
brings non-rel support
django.contrib.* Sadly, some of your may be broken, but not
the admin
erm... OKAY WHAT’S SO COOL ABOUT THIS THEN?
No anges n ded. WHAT’S SO COOL ABOUT THIS THEN?
No anges n ded. NOBODY’S GONNA TOUCH YOUR PRECIOUS BUILTINS.
ABOUT THIS THEN?
NOBODY’S GONNA TOUCH YOUR PRECIOUS BUILTINS. REDUCED IMPEDANCE MISSMATCH
WHAT ELSE? at’s c l
NEW FIELDS
AGGREGATIONS
GRIDFS
CACHING
MAP / REDUCE >>> for pair in Article.objects.map_reduce(_map, _reduce, 'wordcount'):
... print pair.key, pair.value
NEW INDEXES class Club(models.Model): location = ListField() rating = models.FloatField()
... class MongoMeta: indexes = [ [('rating', -1)], {'fields': [('location', '2d')], 'min': -42, 'max': 42}, ]
TONS OF DOCS Plus: (which never hurts)
Su estions
RAW QUERIES MyModel.objects.raw_query(field=“value”)
EMBEDD IF POSSIBLE class Comment(models.Model): created_on = models.DateTimeField() author =
EmbeddedModelField('Author') text = models.TextField()
RE-THINK YOUR MODELS class Post(models.Model): title = models.CharField() text =
models.TextField() tags = ListField() # Note: Use defer comments = ListField(EmbeddedModelField('Comment'))
DO NOT USE IT EVERYWHERE MONGODB_MANAGED_APPS = ['myapp'] MONGODB_MANAGED_MODELS =
['myapp.MongoDBModel']
SERVE STATIC FILES GridFSStorage + nginx-GridFS
AGGREGATIONS? MAP/REDUCE class Min(MongoAggregate): initial_value = float('inf') reduce_template = '{alias}
= ({lookup}<{alias})?{lookup}:{alias}' class Max(MongoAggregate): initial_value = float('-inf') reduce_template = '{alias} = ({lookup}>{alias})?{lookup}:{alias}'
DATES WORK But, MongoDB does not support month/day queries
DO NOT TRY TO MIGRATE It Wont Work!
CONTRIBUTE The Compiler’s a mess
A away Contribute: http://django-mongodb.org /meta/contributing.html http://groups.google.com /group/django-non-relational