Skip to content

Commit

Permalink
Merge pull request #556 from benjaoming/rest-field-example
Browse files Browse the repository at this point in the history
Add more guidance for django-rest-framework
  • Loading branch information
benjaoming committed Jun 11, 2020
2 parents 58e1a6a + ead6003 commit 860cd7f
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -441,8 +441,20 @@ conversions happening in different directions.
Usage with Django REST Framework
--------------------------------

Make sure that ``djmoney`` is in the ``INSTALLED_APPS`` of your ``settings.py`` and MoneyFields to automatically
work with Django REST Framework.
Make sure that ``djmoney`` and is in the ``INSTALLED_APPS`` of your
``settings.py`` and that ``rest_framework`` has been installed. MoneyField will
automatically register a serializer for Django REST Framework through
``djmoney.apps.MoneyConfig.ready()``.

You can add a serializable field the following way:

.. code:: python
from djmoney.contrib.django_rest_framework import MoneyField
class Serializers(serializers.Serializer):
my_computed_prop = MoneyField(max_digits=10, decimal_places=2)
Built-in serializer works in the following way:

Expand Down

0 comments on commit 860cd7f

Please sign in to comment.