diff --git a/docs/release_notes.rst b/docs/release_notes.rst index 0272a572..7fadbcd8 100644 --- a/docs/release_notes.rst +++ b/docs/release_notes.rst @@ -16,7 +16,7 @@ Breaking changes: If your codebase uses :py:class:`~pynamodb.attributes.BinaryAttribute` or :py:class:`~pynamodb.attributes.BinarySetAttribute`, go over the attribute declarations and mark them accordingly. * When using binary attributes, the return value of :meth:`~pynamodb.models.Model.serialize` will no longer be JSON-serializable - since it will contain :code:`bytes` objects. Use :meth:`~pynamodb.models.Model.to_dynamodb_dict` + since it will contain :code:`bytes` objects. Use :meth:`~pynamodb.attributes.AttributeContainer.to_dynamodb_dict` and :meth:`~pynamodb.attributes.AttributeContainer.to_simple_dict` for JSON-serializable mappings. for a safe JSON-serializable representation. * Python 3.6 is no longer supported. diff --git a/pynamodb/attributes.py b/pynamodb/attributes.py index ce750bf4..964b5ae6 100644 --- a/pynamodb/attributes.py +++ b/pynamodb/attributes.py @@ -929,7 +929,7 @@ class MapAttribute(Attribute[Mapping[_KT, _VT]], AttributeContainer, metaclass=M For example, below we define "MyModel" which contains a MapAttribute "my_map": class MyModel(Model): - my_map = MapAttribute(attr_name="dynamo_name", default={}) + my_map = MapAttribute(attr_name="dynamo_name", default=dict) When instantiated in this manner (as a class attribute of an AttributeContainer class), the MapAttribute class acts as an instance of the Attribute class. The instance stores data about the attribute (in this