0

I am new in Django with MongoDB. Please suggest how to create models using MongoDB with relationship like ForeignKey, ManyToManyFields etc...

Manish Kumar
  • 39
  • 1
  • 8

1 Answers1

0

I suggest you use MongoEngine for Django project

please refer MongoEngine document here: http://docs.mongoengine.org/index.html

using Mongoengine you can simply create a model like this:

class YourModel(Document): # Define Model in using MongoEngine
    id = IntField(unique=True) # define Integer field
    percentage = FloatField(default=0.00) # define float field
    user = ReferenceField('User') # foreignkey

All the fields are the same as Django as an ex: IntField, FloatField And You can use relational field (foreign key) using ReferenceField.

For more information, please follow the documentation (http://docs.mongoengine.org/index.html)