Search code examples
pythondjangomongodbdjongo

How to store array of objects in MongoDB from django


I am using MongoDB as a database for my project and I want to store a list of the dictionary as an array of objects in an object in MongoDB from Django. For Eg. {"id":1,"products":[{...},{...},{...},{...}..]} how do I define my model and how to query this. please help


Solution

  • Have a look at Djongo to start with maybe, it's database connector for MongoDB that uses the default Django ORM. So you will define your models just like you do with mysql, sqlite, etc. But it enables some extra features.