0

I am using mongoengine in django.I want to create a objectid which I can insert in nested object wholesalers of firm collection

class wholesaler(EmbeddedDocument):
    wid                 =   ObjectIdField()
    name                =   StringField(required = True,min_length = 3)

class firm(Document):
    name                = StringField(required=True)
    wholesalers         = ListField(EmbeddedDocumentField(wholesaler))

In View.py

wholesaler1 = wholesaler(wid = ??
                         ,name = '')

1 Answer 1

2
import bson
bson.objectid.ObjectId()
=> ObjectId('55dada4065d1ac2052207776')
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.