Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Django with MongoDB using MongoEngine

In this presentation i have covered the basics to integrate MongoDB in a Django Application. I have covered basics of Django, Mongo DB, Mongo Engine and an easy way to integrate it with Django

Django with MongoDB using MongoEngine

  1. 1. Web development with Django and MongoDB
  2. 2. What is Django ➢ A high level web framework for rapid development ➢ Free and Open Source ➢ It's written in and for Python ➢ Very useful default admin panel ➢ Form Handling ➢ Templates – It has it's own template engine ➢ Object Relational Mapping (ORM) ➢ Model-View-Template
  3. 3. Architecture
  4. 4. Model class Person(models.Model): first_name = models.CharField(max_length=30) last_name = models.CharField(max_length=30)
  5. 5. Forms #Basic Form class PersonForm(forms.Form): first_name = forms.CharField(max_length=100) last_name = forms.CharField(max_length=100) #Model Forms class PersonForm(forms.ModelForm): class Meta: model = Person
  6. 6. View def person_by_firstname(request,first_name): person = Person.objects.find(first_name = first_name) return render_to_response('person.html', {'person' : person})
  7. 7. MongoDB ➢ Scalable High-performance Open Source, NoSQL database ➢ Query without joins ➢ Stores data in document model ➢ Nested Queries ➢ Map/Reduce for Aggregation
  8. 8. What is Document Model
  9. 9. Document Model - Denormalized
  10. 10. Nested Queries ● db.user.find({contact : {phone : “xyz”}}); ● db.user.find({contact : {email : “xyz@example.com”}});
  11. 11. Comparison with RDBMS RDBMS(MySql, Postgres) MongoDB Tables Collections Records/Rows Documents/Objects Queries Return Record Queries Return Cursor
  12. 12. Django with Mongo ● At the core of Django is it's ORM Mongo Engine ● An ORM written in Python for MongoDB ● Say bye to Migrations. ● It's similar to Django ORM ● pip install mongoengine
  13. 13. Mongo Engine Model
  14. 14. Collecting things in View
  15. 15. Connecting to Database
  16. 16. MongoEngine is good ● Constantly maintained ● Works like Django ORM ● A replaceable component in Django
  17. 17. Any Alternative? - Yes Django-nonrel ● Not maintained anymore ● Available for old django versions(maybe 1.4 or 1.5)
  18. 18. When should you use MongoDB ● You are starting a project with design freedom ● Your application has a lot of Geo-location data ● You have a high-volume traffic ● You want auto-sharding
  19. 19. Thank You

    Be the first to comment

    Login to see the comments

  • powerirs

    Jul. 26, 2016
  • RamSharma10

    Aug. 8, 2016
  • bluehopper94

    Jul. 10, 2018
  • hosseinj

    May. 29, 2019
  • ShubhamRaj51

    Aug. 25, 2019

In this presentation i have covered the basics to integrate MongoDB in a Django Application. I have covered basics of Django, Mongo DB, Mongo Engine and an easy way to integrate it with Django

Views

Total views

2,202

On Slideshare

0

From embeds

0

Number of embeds

1

Actions

Downloads

32

Shares

0

Comments

0

Likes

5

×