hmarr/mongoengine — Issue #438: queryset insert method and documents with id
Author: anti-social
Created: 2012-02-23 17:40:32+00:00
State: open

I need to insert a lot of documents with already generated id, but I can't do that with mongoengine:

```python
group = ImportProductGroup(name='Test 1', id=ObjectId())
ImportProductGroup.objects.insert([group])
```

```
----> 1 ImportProductGroup.objects.insert([group])

/home/alexk/v/uaprom-arch/lib/python2.7/site-packages/mongoengine/queryset.pyc in insert(self, doc_or_docs, load_bulk)
810 if doc.pk:
811 msg = "Some documents have ObjectIds use doc.update() instead"
--> 812 raise OperationError(msg)
813 raw.append(doc.to_mongo())
814

OperationError: Some documents have ObjectIds use doc.update() instead
```

But I can do that with pymongo:

```python
group_collection = getattr(db, ImportProductGroup._meta['collection'])
group_collection.insert([group.to_mongo()])
```