{ "info": { "author": "Tom Christie", "author_email": "tom@tomchristie.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 4 - Beta", "Environment :: Web Environment", "Framework :: Django", "Intended Audience :: Developers", "License :: OSI Approved :: BSD License", "Natural Language :: English", "Operating System :: OS Independent", "Programming Language :: Python :: 2", "Programming Language :: Python :: 2.7", "Programming Language :: Python :: 3", "Programming Language :: Python :: 3.5", "Programming Language :: Python :: 3.6", "Topic :: Internet :: WWW/HTTP" ], "description": "
\n \n \"Travis\n \n \n \"django-rest-marshmallow\n \n \n \"marshmallow\n \n
\n\n---\n\n# [django-rest-marshmallow](https://marshmallow-code.github.io/django-rest-marshmallow/)\n\n[Marshmallow schemas][marshmallow] for Django REST framework.\n\n---\n\n## Overview\n\n`django-rest-marshmallow` provides an alternative serializer implementation to the built-in serializers, by using the python [marshmallow] library, but exposing the same API as REST framework's `Serializer` class.\n\n## Requirements\n\n* Python (2.7, 3.5+)\n* Django REST framework (3.8+)\n* Marshmallow (2.15+ and 3.0.0b18+)\n\n## Installation\n\nInstall using `pip`...\n\n```bash\n$ pip install django-rest-marshmallow\n```\n\n---\n\n## Usage\n\nDefine your schemas as you would with marshmallow, but importing the `Schema` class from `rest_marshmallow` instead.\n\n```python\nfrom rest_marshmallow import Schema, fields\n\nclass CustomerSchema(Schema):\n name = fields.String()\n email = fields.Email()\n created_at = fields.DateTime()\n```\n\nThe Schema class has the same interface as a Django REST framework serializer, so you can use it in your generic views...\n\n```python\nclass CustomerListView(generics.ListAPIView):\n queryset = Customer.objects.all()\n serializer_class = CustomerSchema\n```\n\nOr use the serializer API directly, for either serialization...\n\n```python\nserializer = CustomerSchema(queryset, many=True)\nreturn Response(serializer.data)\n```\n\nOr for validation...\n\n```python\nserializer = CustomerSchema(data=request.data)\nserializer.is_valid(raise_exception=True)\nserializer.validated_data\n```\n\n#### Instance create and update\n\nIf you want to support `serializer.save()` you'll need to define the `.create()` and/or `.update()` methods explicitly.\n\n```python\nclass CustomerSchema(Schema):\n name = fields.String()\n email = fields.Email()\n created_at = fields.DateTime()\n\n def create(self, validated_data):\n return Customer.objects.create(**validated_data)\n\n def update(self, instance, validated_data):\n for key, value in validated_data.items():\n setattr(instance, key, value)\n instance.save()\n return instance\n```\n\nYou can now use `.save()` from your view code\u2026\n\n```python\nserializer = CustomerSchema(data=request.data)\nserializer.is_valid(raise_exception=True)\nserializer.save()\nreturn Response(serializer.data, status=status.HTTP_201_CREATED)\n```\n\nOr use the schema together with generic views that create or update instances...\n\n```python\nclass CustomerListView(generics.ListCreateAPIView):\n queryset = Customer.objects.all()\n serializer_class = CustomerSchema\n```\n\nNote that you should always use the `create()` and `update()` methods instead of overriding the `make_object()` marshmallow method.\n\n#### Nested representations\n\nFor nested representations, use marshmallow's standard `Nested` field as usual.\n\n```python\nfrom rest_marshmallow import fields, Schema\n\nclass ArtistSchema(Schema):\n name = fields.String()\n\nclass AlbumSchema(Schema):\n title = fields.String()\n release_date = fields.Date()\n artist = fields.Nested(ArtistSchema)\n```\n\n#### Excluding fields\n\nThe marshmallow `only` and `exclude` arguments are also valid as serializer arguments:\n\n```python\nserializer = CustomerSchema(queryset, many=True, only=('name', 'email'))\nreturn Response(serializer.data)\n```\n\n---\n\n## Testing\n\nInstall testing requirements.\n\n```bash\n$ pip install -r requirements.txt\n```\n\nRun with runtests.\n\n```bash\n$ ./runtests.py\n```\n\nYou can also use the excellent [tox](http://tox.readthedocs.org/en/latest/) testing tool to run the tests against all supported versions of Python and Django. Install tox globally, and then simply run:\n\n```bash\n$ tox\n```\n\n## Documentation\n\nTo build the documentation, you'll need to install `mkdocs`.\n\n```bash\n$ pip install mkdocs\n```\n\nTo preview the documentation:\n\n```bash\n$ mkdocs serve\nRunning at: http://127.0.0.1:8000/\n```\n\nTo build the documentation:\n\n```bash\n$ mkdocs build\n```\n\n\n[marshmallow]: https://marshmallow.readthedocs.org/en/latest/\n\n\n", "description_content_type": "text/markdown", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/marshmallow-code/django-rest-marshmallow", "keywords": "", "license": "BSD", "maintainer": "Steven Loria", "maintainer_email": "sloria1@gmail.com", "name": "django-rest-marshmallow", "package_url": "https://pypi.org/project/django-rest-marshmallow/", "platform": "", "project_url": "https://pypi.org/project/django-rest-marshmallow/", "project_urls": { "Homepage": "https://github.com/marshmallow-code/django-rest-marshmallow" }, "release_url": "https://pypi.org/project/django-rest-marshmallow/4.0.1/", "requires_dist": null, "requires_python": "", "summary": "Marshmallow schemas for Django REST framework", "version": "4.0.1" }, "last_serial": 5611061, "releases": { "1.0.0": [ { "comment_text": "", "digests": { "md5": "548198faa8dc1cb187acb951b9fe1485", "sha256": "9837b8e8ac620b1016a0b4c6bec5e746d47a178e605b4dbf040081fdf55342a8" }, "downloads": -1, "filename": "django_rest_marshmallow-1.0.0-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "548198faa8dc1cb187acb951b9fe1485", "packagetype": "bdist_wheel", "python_version": "2.7", "requires_python": null, "size": 3342, "upload_time": "2015-09-11T11:45:36", "url": "https://files.pythonhosted.org/packages/1e/c8/4027a5c26919da84caa32761507b9c41018703f492a14c9ff2d3b882c1ca/django_rest_marshmallow-1.0.0-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "1347e2e17894c742a9d4e21dd9aab162", "sha256": "78eef04121c68db5ac45df47a664bcfb51148909813ddd6edd7a850593dfff6d" }, "downloads": -1, "filename": "django-rest-marshmallow-1.0.0.tar.gz", "has_sig": false, "md5_digest": "1347e2e17894c742a9d4e21dd9aab162", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 3694, "upload_time": "2015-09-11T11:45:18", "url": "https://files.pythonhosted.org/packages/10/c9/aaa29602809b4f775eedd6c8ada61b5f768641f72efd1a7a2978e477d8b1/django-rest-marshmallow-1.0.0.tar.gz" } ], "1.0.1": [ { "comment_text": "", "digests": { "md5": "8e4ef055bbdc45d3977c6dbefbfb09dc", "sha256": "cf8d695389e9f9d0576f0faaeab5e23eb3183a9a1a423c55f6d771f15b9bffdb" }, "downloads": -1, "filename": "django_rest_marshmallow-1.0.1-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "8e4ef055bbdc45d3977c6dbefbfb09dc", "packagetype": "bdist_wheel", "python_version": "3.5", "requires_python": null, "size": 4996, "upload_time": "2016-10-02T14:07:17", "url": "https://files.pythonhosted.org/packages/60/18/df6d9ab5d7214907bac0cb3385ad592614cef3ef21c40e193db17c02198e/django_rest_marshmallow-1.0.1-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "5d8ab14dd3859e4ff9eae0fab90ffd86", "sha256": "91cf526d60aa5a56c94fe158b65e106ca9a236b4650c89fe2acafb3e85855ad5" }, "downloads": -1, "filename": "django-rest-marshmallow-1.0.1.tar.gz", "has_sig": false, "md5_digest": "5d8ab14dd3859e4ff9eae0fab90ffd86", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 3233, "upload_time": "2016-10-02T14:07:05", "url": "https://files.pythonhosted.org/packages/38/61/9f552983e37c68a83e0fa5e4fd91d041dbf22eaef9e5fb7ee62552f6e328/django-rest-marshmallow-1.0.1.tar.gz" } ], "2.0.0": [ { "comment_text": "", "digests": { "md5": "a9e969bda47ff92b388a859f8d378457", "sha256": "27809e9b5f5d7fda0f913358038f00447a576751ca59af8c3a5004223b175020" }, "downloads": -1, "filename": "django_rest_marshmallow-2.0.0-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "a9e969bda47ff92b388a859f8d378457", "packagetype": "bdist_wheel", "python_version": "3.5", "requires_python": null, "size": 4820, "upload_time": "2016-10-09T15:25:48", "url": "https://files.pythonhosted.org/packages/12/d3/fd8dd8d79f46e3f8781f91d6613fea4500a8375c6280720d3081ee9acde0/django_rest_marshmallow-2.0.0-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "7af818d99c6dd81391322285d1826a43", "sha256": "300043ac6daf947381a61b375ea8d646934bdd72d921b7ed04082df8d8d9853d" }, "downloads": -1, "filename": "django-rest-marshmallow-2.0.0.tar.gz", "has_sig": false, "md5_digest": "7af818d99c6dd81391322285d1826a43", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 3245, "upload_time": "2016-10-09T15:25:44", "url": "https://files.pythonhosted.org/packages/df/9e/4be25acae01249725e564817248007a8b33344e5ea8d64728ca463fb5d28/django-rest-marshmallow-2.0.0.tar.gz" } ], "3.0.0": [ { "comment_text": "", "digests": { "md5": "4b494610318db183f9236e16306f1271", "sha256": "e87c806a81ca1742fd6e015f67ba785f83d86d9752bb45ba8b6b7bfdadcbdcee" }, "downloads": -1, "filename": "django_rest_marshmallow-3.0.0-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "4b494610318db183f9236e16306f1271", "packagetype": "bdist_wheel", "python_version": "3.5", "requires_python": null, "size": 4855, "upload_time": "2017-05-29T17:42:03", "url": "https://files.pythonhosted.org/packages/fc/84/08eb84b6b5313e8137dd619d28ed7f7d4f63cb3b6c0328fdcea2a1e87007/django_rest_marshmallow-3.0.0-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "179ff9c27641c8b339d010009b40b29d", "sha256": "788143d0eb7632d3e3c9bd14e44734812cf13baf44e7e71f94b169f00f3f633f" }, "downloads": -1, "filename": "django-rest-marshmallow-3.0.0.tar.gz", "has_sig": false, "md5_digest": "179ff9c27641c8b339d010009b40b29d", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 3268, "upload_time": "2017-05-29T17:42:00", "url": "https://files.pythonhosted.org/packages/eb/6c/24e532f1e9dba0b51a2d62b065c5a3f39b5f23a32e84d6cd9b941ab4fcc7/django-rest-marshmallow-3.0.0.tar.gz" } ], "3.1.0": [ { "comment_text": "", "digests": { "md5": "38da05dadd6a3e324e65f942e0344f09", "sha256": "bb072e7a9fa4bd1ffbe40e7248e4815dea64aaf2614d0603a99e104b6564af01" }, "downloads": -1, "filename": "django_rest_marshmallow-3.1.0-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "38da05dadd6a3e324e65f942e0344f09", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 3531, "upload_time": "2018-02-12T03:18:08", "url": "https://files.pythonhosted.org/packages/e3/33/e675c863b29170e2fdadc247b88ca04115269196539410d03df4e6ab4c56/django_rest_marshmallow-3.1.0-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "7881016d6dcf6264217aaf205c0b7ea2", "sha256": "bc1f95a01234e81fc85b22ce37e345161d0c65b2d09c95c3980207e437eddbe8" }, "downloads": -1, "filename": "django-rest-marshmallow-3.1.0.tar.gz", "has_sig": false, "md5_digest": "7881016d6dcf6264217aaf205c0b7ea2", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4543, "upload_time": "2018-02-12T03:18:09", "url": "https://files.pythonhosted.org/packages/eb/db/39a4ee654eeaf845e9fc57ecc7e199e013549bc00fddf2be48ed02222a63/django-rest-marshmallow-3.1.0.tar.gz" } ], "3.1.1": [ { "comment_text": "", "digests": { "md5": "e01341071e6134266395fd4085fd281d", "sha256": "d8ce7c789ef9efda7251cf4648679082f131ba9b56c291290a581b11d6c6812d" }, "downloads": -1, "filename": "django_rest_marshmallow-3.1.1-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "e01341071e6134266395fd4085fd281d", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 4069, "upload_time": "2018-05-26T12:56:08", "url": "https://files.pythonhosted.org/packages/48/a2/221c8bf3b57b193b4d3a457596090f1ba6dcbfd1b63c72b00c636062d52c/django_rest_marshmallow-3.1.1-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "3ac41cb124c6ff9fb670dc085d2bbc1a", "sha256": "17490015420a8d62bebfa29193e701459b4aff9ff3f0155b1814b7662b95279a" }, "downloads": -1, "filename": "django-rest-marshmallow-3.1.1.tar.gz", "has_sig": false, "md5_digest": "3ac41cb124c6ff9fb670dc085d2bbc1a", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5241, "upload_time": "2018-05-26T12:56:09", "url": "https://files.pythonhosted.org/packages/c2/1f/a199d7c16970f5f8ecf062d1dcfca0df80b60bb24ad82dec3ff5a2c9636c/django-rest-marshmallow-3.1.1.tar.gz" } ], "4.0.0": [ { "comment_text": "", "digests": { "md5": "c5e25defb88d5a4b54d75675da8c5298", "sha256": "8646aeff382ad91270ca5508f17cf7e9c39e689b50e699a23837f3f9e3cfd9ce" }, "downloads": -1, "filename": "django_rest_marshmallow-4.0.0-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "c5e25defb88d5a4b54d75675da8c5298", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 4799, "upload_time": "2019-02-14T21:50:04", "url": "https://files.pythonhosted.org/packages/b6/58/12091dc0607da44c37f9b7eafa9e618610b4355510007a102a11633a29f9/django_rest_marshmallow-4.0.0-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "f82ec08df658ae110df7b8063bbd66d9", "sha256": "15b3fea9cb5cb93bb50c5eb9e71e74c17192b09d5a821e6be6ee257c584dc1fc" }, "downloads": -1, "filename": "django-rest-marshmallow-4.0.0.tar.gz", "has_sig": false, "md5_digest": "f82ec08df658ae110df7b8063bbd66d9", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5308, "upload_time": "2019-02-14T21:50:05", "url": "https://files.pythonhosted.org/packages/56/f9/82bb2c1ab8750fe3794ed4cecd2762390abf26a8bc572ca71f37bf43a996/django-rest-marshmallow-4.0.0.tar.gz" } ], "4.0.1": [ { "comment_text": "", "digests": { "md5": "5d2c7baf550bab6900b2d2ac7f022dde", "sha256": "4d0a90a517ce265eae680f96b2288da665db58e12538a1614dba64d7259f0b1e" }, "downloads": -1, "filename": "django_rest_marshmallow-4.0.1-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "5d2c7baf550bab6900b2d2ac7f022dde", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 4806, "upload_time": "2019-07-31T03:16:09", "url": "https://files.pythonhosted.org/packages/7e/13/82045dc8ace385f5bc9422217f80ece56cf1327ad905bff110931997432f/django_rest_marshmallow-4.0.1-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "52e8474d366ab37ec1f1400b31a61ab6", "sha256": "0856a70366293fa6f33fcf1bf94d3bbb7850268ff14006cc828c04d8dd4a661c" }, "downloads": -1, "filename": "django-rest-marshmallow-4.0.1.tar.gz", "has_sig": false, "md5_digest": "52e8474d366ab37ec1f1400b31a61ab6", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5266, "upload_time": "2019-07-31T03:16:10", "url": "https://files.pythonhosted.org/packages/eb/21/34a420eabf76938ba1e643458fabf402fd8c2169b24cbef7f590f272df9c/django-rest-marshmallow-4.0.1.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "5d2c7baf550bab6900b2d2ac7f022dde", "sha256": "4d0a90a517ce265eae680f96b2288da665db58e12538a1614dba64d7259f0b1e" }, "downloads": -1, "filename": "django_rest_marshmallow-4.0.1-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "5d2c7baf550bab6900b2d2ac7f022dde", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 4806, "upload_time": "2019-07-31T03:16:09", "url": "https://files.pythonhosted.org/packages/7e/13/82045dc8ace385f5bc9422217f80ece56cf1327ad905bff110931997432f/django_rest_marshmallow-4.0.1-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "52e8474d366ab37ec1f1400b31a61ab6", "sha256": "0856a70366293fa6f33fcf1bf94d3bbb7850268ff14006cc828c04d8dd4a661c" }, "downloads": -1, "filename": "django-rest-marshmallow-4.0.1.tar.gz", "has_sig": false, "md5_digest": "52e8474d366ab37ec1f1400b31a61ab6", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5266, "upload_time": "2019-07-31T03:16:10", "url": "https://files.pythonhosted.org/packages/eb/21/34a420eabf76938ba1e643458fabf402fd8c2169b24cbef7f590f272df9c/django-rest-marshmallow-4.0.1.tar.gz" } ] }