O slideshow foi denunciado.
Seu SlideShare está sendo baixado. ×

Django mongodb -djangoday_

Anúncio
Anúncio
Anúncio
Anúncio
Anúncio
Anúncio
Anúncio
Anúncio
Anúncio
Anúncio
Anúncio
Anúncio
Próximos SlideShares
JavaScript: Patterns, Part  2
JavaScript: Patterns, Part 2
Carregando em…3
×

Confira estes a seguir

1 de 32 Anúncio
Anúncio

Mais Conteúdo rRelacionado

Quem viu também gostou (20)

Anúncio

Semelhante a Django mongodb -djangoday_ (20)

Anúncio

Mais recentes (20)

Django mongodb -djangoday_

  1. 1. So you want to use DJANGO AND MONGODB @flaper87
  2. 2. DJANGO AND MONGODB THAT’S COOL, but you need to know A COUPLE OF THINGS
  3. 3. LIKE: WHAT ARE THE OPTIONS?
  4. 4. ( http://mongoengine.org ) An object-document mapper to connect Python and MongoDB
  5. 5. Mongokit ( http://namlook.github.com/mongokit/ ) Another ODM that takes mongodb into the web
  6. 6. OR, OF COURSE
  7. 7. DJANGO MONGODB ENGINE (A MongoDB backend for Django)
  8. 8. DJANGO-NONREL A good and up to date Django fork that brings non-rel support
  9. 9. Sadly, some of your django.contrib.* may be broken, but not the admin
  10. 10. erm... OKAY WHAT’S SO COOL ABOUT THIS THEN?
  11. 11. WHAT’S SO COOL ABOUT THIS THEN? No changes needed.
  12. 12. ABOUT THIS THEN? No changes needed. NOBODY’S GONNA TOUCH YOUR PRECIOUS BUILTINS.
  13. 13. NOBODY’S GONNA TOUCH YOUR PRECIOUS BUILTINS. REDUCED IMPEDANCE MISSMATCH
  14. 14. That’s cool WHAT ELSE?
  15. 15. NEW FIELDS
  16. 16. AGGREGATIONS
  17. 17. GRIDFS
  18. 18. CACHING
  19. 19. MAP / REDUCE >>> for pair in Article.objects.map_reduce(_map, _reduce, 'wordcount'): ... print pair.key, pair.value
  20. 20. NEW INDEXES class Club(models.Model): location = ListField() rating = models.FloatField() ... class MongoMeta: indexes = [ [('rating', -1)], {'fields': [('location', '2d')], 'min': -42, 'max': 42}, ]
  21. 21. Plus: TONS OF DOCS (which never hurts)
  22. 22. Suggestions
  23. 23. RAW QUERIES MyModel.objects.raw_query(field=“value”)
  24. 24. EMBEDD IF POSSIBLE class Comment(models.Model): created_on = models.DateTimeField() author = EmbeddedModelField('Author') text = models.TextField()
  25. 25. RE-THINK YOUR MODELS class Post(models.Model): title = models.CharField() text = models.TextField() tags = ListField() # Note: Use defer comments = ListField(EmbeddedModelField('Comment'))
  26. 26. DO NOT USE IT EVERYWHERE MONGODB_MANAGED_APPS = ['myapp'] MONGODB_MANAGED_MODELS = ['myapp.MongoDBModel']
  27. 27. SERVE STATIC FILES GridFSStorage + nginx-GridFS
  28. 28. 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}'
  29. 29. DATES WORK But, MongoDB does not support month/day queries
  30. 30. DO NOT TRY TO MIGRATE It Wont Work!
  31. 31. CONTRIBUTE The Compiler’s a mess
  32. 32. Ask away http://groups.google.com /group/django-non-relational Contribute: http://django-mongodb.org /meta/contributing.html

×