Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Django

flaper87
April 24, 2012
710

 Django

flaper87

April 24, 2012
Tweet

Transcript

  1. THAT’S COOL, but you n d to know A COUPLE

    OF THINGS DJANGO AND MONGODB
  2. Another ODM that takes mongodb into the web Mongokit (

    http://namlook.github.com/mongokit/ )
  3. NEW INDEXES class Club(models.Model): location = ListField() rating = models.FloatField()

    ... class MongoMeta: indexes = [ [('rating', -1)], {'fields': [('location', '2d')], 'min': -42, 'max': 42}, ]
  4. RE-THINK YOUR MODELS class Post(models.Model): title = models.CharField() text =

    models.TextField() tags = ListField() # Note: Use defer comments = ListField(EmbeddedModelField('Comment'))
  5. 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}'