diff --git a/mongoengine/fields.py b/mongoengine/fields.py index 5b2f14a4..55e5addb 100644 --- a/mongoengine/fields.py +++ b/mongoengine/fields.py @@ -505,10 +505,11 @@ class BinaryField(BaseField): return pymongo.binary.Binary(value) def to_python(self, value): - return unicode(value) + # Returns str not unicode as this is binary data + return str(value) def validate(self, value): assert isinstance(value, str) if self.max_bytes is not None and len(value) > self.max_bytes: - raise ValidationError('Binary value is too long') \ No newline at end of file + raise ValidationError('Binary value is too long') diff --git a/mongoengine/queryset.py b/mongoengine/queryset.py index 40779ab7..396a745c 100644 --- a/mongoengine/queryset.py +++ b/mongoengine/queryset.py @@ -918,7 +918,7 @@ class QuerySetManager(object): opts = {'capped': True, 'size': max_size} if max_documents: opts['max'] = max_documents - self._collection = db.create_collection(collection, opts) + self._collection = db.create_collection(collection, **opts) else: self._collection = db[collection]