Table Of Contents

⚠ Documentation version

These are the Git version docs. Docs for 0.4 (PyPI) are here.

Help out!

To make this documentation even better, we'd love to receive your feedback and suggestions for improvement!

Fields

This is a reference of both fields that are implemented in djangotoolbox and fields specific to MongoDB.

(In signatures, ... represents arbitrary positional and keyword arguments that are passed to django.db.models.Field.)

in djangotoolbox

class djangotoolbox.fields.ListField(item_field=None, ...)

Field representing a Python list.

If the optional keyword argument ordering is given, it must be a callable that is passed to list.sort() as key argument. If ordering is given, the items in the list will be sorted before sending them to the database.

class djangotoolbox.fields.SetField(item_field=None, ...)

Field representing a Python set.

class djangotoolbox.fields.DictField(item_field=None, ...)

Field representing a Python dict.

The field type conversions described in AbstractIterableField only affect values of the dictionary, not keys.

Depending on the backend, keys that aren’t strings might not be allowed.

class djangotoolbox.fields.EmbeddedModelField(embedded_model=None, ...)

Field that allows you to embed a model instance.

Parameters:model – (optional) The model class that shall be embedded (may also be passed as string similar to relation fields)
class djangotoolbox.fields.BlobField(...)

A field for storing blobs of binary data.

The value might either be a string (or something that can be converted to a string), or a file-like object.

In the latter case, the object has to provide a read method from which the blob is read.

in django_mongodb_engine

class django_mongodb_engine.fields.GridFSField(delete=True, versioning=False, ...)

GridFS field to store large chunks of data (blobs) in GridFS.

Model instances keep references (ObjectIds) to GridFS files (gridfs.GridOut) which are fetched on first attribute access.

Parameters:delete

Whether to delete the data stored in the GridFS (as GridFS files) when model instances are deleted (default: True).

Note that this doesn’t have any influence on what happens if you update the blob value by assigning a new file, in which case the old file is always deleted.

class django_mongodb_engine.fields.GridFSString(delete=True, versioning=False, ...)

Similar to GridFSField, but the data is represented as a bytestring on Python side. This implies that all data has to be copied into memory, so GridFSString is for smaller chunks of data only.