%global _empty_manifest_terminate_build 0 Name: python-djangorestframework-serializer-extensions Version: 2.0.1 Release: 1 Summary: Extensions to DRY up Django Rest Framework serializers License: BSD URL: https://github.com/evenicoulddoit/django-rest-framework-serializer-extensions Source0: https://mirrors.nju.edu.cn/pypi/web/packages/4b/41/77dd0e5f1b5ae1f31900f27b7cbf5c9246b24de8ecac97db7cba2d691015/djangorestframework-serializer-extensions-2.0.1.tar.gz BuildArch: noarch Requires: python3-hashids %description # Django REST framework serializer extensions **A collection of useful tools to DRY up your Django Rest Framework serializers** Full documentation: http://django-rest-framework-serializer-extensions.readthedocs.io/ [![build-status-image]][travis] [![coverage-status-image]][codecov] [![pypi-version]][pypi] ## Overview Serializer extensions reduces the need for *very similar* serializers, by allowing the fields to be defined on a *per-view/request* basis. Fields can be whitelisted, blacklisted, and child serializers can be optionally expanded. Whatever fields you choose to use, your querysets can be *optimized automatically* to make the fewest database calls possible. Support for [HashIds](https://github.com/davidaurelio/hashids-python) is also provided. If you're currently exposing your internal IDs over a public API, we suggest you consider switching to HashIds instead. **:star: Lovingly open-sourced by [Housekeep](https://housekeep.com).** ## Requirements Tested against: * Python (3.6, 3.7, 3.8) * [Django](https://github.com/django/django) (2.1, 2.2, 3.0) * [Django REST Framework](https://github.com/tomchristie/django-rest-framework) (3.9, 3.10, 3.11) * [HashIds](https://github.com/davidaurelio/hashids-python) (>1.0) ## Installation Install using `pip`: ```bash $ pip install djangorestframework-serializer-extensions ``` And add `rest_framework_serializer_extensions` to your `INSTALLED_APPS` setting: ```py INSTALLED_APPS = ( ... 'rest_framework_serializer_extensions' ) ``` ## Basic Usage To activate the serializer extensions, add the `SerializerExtensionsMixin` to your serializers: ```py # serializers.py from rest_framework.serializers import ModelSerializer from rest_framework_serializer_extensions.serializers import SerializerExtensionsMixin ... class OwnerSerializer(SerializerExtensionsMixin, ModelSerializer): class Meta: model = models.Owner fields = ('id', 'name') expandable_fields = dict( organization=OrganizationSerializer, cars=dict( serializer=SkuSerializer, many=True ) ) ``` And add the `SerializerExtensionsAPIViewMixin` to your API views: ```py from rest_framework.generics import RetrieveAPIView from rest_framework_serializer_extensions.views import SerializerExtensionsAPIViewMixin class RetriveOwnerAPIView(SerializerExtensionsAPIViewMixin, RetrieveAPIView): ... ``` ## Examples Serializer extensions allows your API to re-use your serializers to fit a variety of use cases. The examples shown below use query parameters to modify the response, but individual views can interact with your serializers in much the same way. ```js >>> GET /owner/x4F/ { "id": 'x4F', "name": 'tyrell', "organization_id": 'kgD' } ``` ```js >>> GET /owner/x4F/?expand=organization { "id": 'x4F', "name": 'tyrell', "organization_id": 'kgD', "organization": { "id": "kgD", "name": "E Corp" } } ``` ```js >>> GET /owner/x4F/?expand=cars__model&exclude=name { "id": 'x4F', "organization_id": 'kgD', "cars": [ { "id": "wf9", "variant": "P100D", "model": { "id": "ncX", "name": "Model S" } } ] } ``` ```js >>> GET /owner/x4F/?expand=cars&only=cars__variant { "cars": [ { "variant": "P100D", } ] } ``` ## Testing Install testing requirements. ```bash $ pip install -r requirements.txt ``` Run with runtests. ```bash $ ./runtests.py ``` You 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: ```bash $ tox ``` ## Documentation To build the documentation, you’ll need to install `mkdocs`. ```bash $ pip install mkdocs ``` To preview the documentation: ```bash $ mkdocs serve Running at: http://127.0.0.1:8000/ ``` To build the documentation: ```bash $ mkdocs build ``` [build-status-image]: https://secure.travis-ci.org/evenicoulddoit/django-rest-framework-serializer-extensions.svg?branch=master [travis]: https://secure.travis-ci.org/evenicoulddoit/django-rest-framework-serializer-extensions?branch=master [coverage-status-image]: https://img.shields.io/codecov/c/github/evenicoulddoit/django-rest-framework-serializer-extensions/master.svg [codecov]: http://codecov.io/github/evenicoulddoit/django-rest-framework-serializer-extensions?branch=master [pypi-version]: https://img.shields.io/pypi/v/djangorestframework-serializer-extensions.svg [pypi]: https://pypi.python.org/pypi/djangorestframework-serializer-extensions %package -n python3-djangorestframework-serializer-extensions Summary: Extensions to DRY up Django Rest Framework serializers Provides: python-djangorestframework-serializer-extensions BuildRequires: python3-devel BuildRequires: python3-setuptools BuildRequires: python3-pip %description -n python3-djangorestframework-serializer-extensions # Django REST framework serializer extensions **A collection of useful tools to DRY up your Django Rest Framework serializers** Full documentation: http://django-rest-framework-serializer-extensions.readthedocs.io/ [![build-status-image]][travis] [![coverage-status-image]][codecov] [![pypi-version]][pypi] ## Overview Serializer extensions reduces the need for *very similar* serializers, by allowing the fields to be defined on a *per-view/request* basis. Fields can be whitelisted, blacklisted, and child serializers can be optionally expanded. Whatever fields you choose to use, your querysets can be *optimized automatically* to make the fewest database calls possible. Support for [HashIds](https://github.com/davidaurelio/hashids-python) is also provided. If you're currently exposing your internal IDs over a public API, we suggest you consider switching to HashIds instead. **:star: Lovingly open-sourced by [Housekeep](https://housekeep.com).** ## Requirements Tested against: * Python (3.6, 3.7, 3.8) * [Django](https://github.com/django/django) (2.1, 2.2, 3.0) * [Django REST Framework](https://github.com/tomchristie/django-rest-framework) (3.9, 3.10, 3.11) * [HashIds](https://github.com/davidaurelio/hashids-python) (>1.0) ## Installation Install using `pip`: ```bash $ pip install djangorestframework-serializer-extensions ``` And add `rest_framework_serializer_extensions` to your `INSTALLED_APPS` setting: ```py INSTALLED_APPS = ( ... 'rest_framework_serializer_extensions' ) ``` ## Basic Usage To activate the serializer extensions, add the `SerializerExtensionsMixin` to your serializers: ```py # serializers.py from rest_framework.serializers import ModelSerializer from rest_framework_serializer_extensions.serializers import SerializerExtensionsMixin ... class OwnerSerializer(SerializerExtensionsMixin, ModelSerializer): class Meta: model = models.Owner fields = ('id', 'name') expandable_fields = dict( organization=OrganizationSerializer, cars=dict( serializer=SkuSerializer, many=True ) ) ``` And add the `SerializerExtensionsAPIViewMixin` to your API views: ```py from rest_framework.generics import RetrieveAPIView from rest_framework_serializer_extensions.views import SerializerExtensionsAPIViewMixin class RetriveOwnerAPIView(SerializerExtensionsAPIViewMixin, RetrieveAPIView): ... ``` ## Examples Serializer extensions allows your API to re-use your serializers to fit a variety of use cases. The examples shown below use query parameters to modify the response, but individual views can interact with your serializers in much the same way. ```js >>> GET /owner/x4F/ { "id": 'x4F', "name": 'tyrell', "organization_id": 'kgD' } ``` ```js >>> GET /owner/x4F/?expand=organization { "id": 'x4F', "name": 'tyrell', "organization_id": 'kgD', "organization": { "id": "kgD", "name": "E Corp" } } ``` ```js >>> GET /owner/x4F/?expand=cars__model&exclude=name { "id": 'x4F', "organization_id": 'kgD', "cars": [ { "id": "wf9", "variant": "P100D", "model": { "id": "ncX", "name": "Model S" } } ] } ``` ```js >>> GET /owner/x4F/?expand=cars&only=cars__variant { "cars": [ { "variant": "P100D", } ] } ``` ## Testing Install testing requirements. ```bash $ pip install -r requirements.txt ``` Run with runtests. ```bash $ ./runtests.py ``` You 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: ```bash $ tox ``` ## Documentation To build the documentation, you’ll need to install `mkdocs`. ```bash $ pip install mkdocs ``` To preview the documentation: ```bash $ mkdocs serve Running at: http://127.0.0.1:8000/ ``` To build the documentation: ```bash $ mkdocs build ``` [build-status-image]: https://secure.travis-ci.org/evenicoulddoit/django-rest-framework-serializer-extensions.svg?branch=master [travis]: https://secure.travis-ci.org/evenicoulddoit/django-rest-framework-serializer-extensions?branch=master [coverage-status-image]: https://img.shields.io/codecov/c/github/evenicoulddoit/django-rest-framework-serializer-extensions/master.svg [codecov]: http://codecov.io/github/evenicoulddoit/django-rest-framework-serializer-extensions?branch=master [pypi-version]: https://img.shields.io/pypi/v/djangorestframework-serializer-extensions.svg [pypi]: https://pypi.python.org/pypi/djangorestframework-serializer-extensions %package help Summary: Development documents and examples for djangorestframework-serializer-extensions Provides: python3-djangorestframework-serializer-extensions-doc %description help # Django REST framework serializer extensions **A collection of useful tools to DRY up your Django Rest Framework serializers** Full documentation: http://django-rest-framework-serializer-extensions.readthedocs.io/ [![build-status-image]][travis] [![coverage-status-image]][codecov] [![pypi-version]][pypi] ## Overview Serializer extensions reduces the need for *very similar* serializers, by allowing the fields to be defined on a *per-view/request* basis. Fields can be whitelisted, blacklisted, and child serializers can be optionally expanded. Whatever fields you choose to use, your querysets can be *optimized automatically* to make the fewest database calls possible. Support for [HashIds](https://github.com/davidaurelio/hashids-python) is also provided. If you're currently exposing your internal IDs over a public API, we suggest you consider switching to HashIds instead. **:star: Lovingly open-sourced by [Housekeep](https://housekeep.com).** ## Requirements Tested against: * Python (3.6, 3.7, 3.8) * [Django](https://github.com/django/django) (2.1, 2.2, 3.0) * [Django REST Framework](https://github.com/tomchristie/django-rest-framework) (3.9, 3.10, 3.11) * [HashIds](https://github.com/davidaurelio/hashids-python) (>1.0) ## Installation Install using `pip`: ```bash $ pip install djangorestframework-serializer-extensions ``` And add `rest_framework_serializer_extensions` to your `INSTALLED_APPS` setting: ```py INSTALLED_APPS = ( ... 'rest_framework_serializer_extensions' ) ``` ## Basic Usage To activate the serializer extensions, add the `SerializerExtensionsMixin` to your serializers: ```py # serializers.py from rest_framework.serializers import ModelSerializer from rest_framework_serializer_extensions.serializers import SerializerExtensionsMixin ... class OwnerSerializer(SerializerExtensionsMixin, ModelSerializer): class Meta: model = models.Owner fields = ('id', 'name') expandable_fields = dict( organization=OrganizationSerializer, cars=dict( serializer=SkuSerializer, many=True ) ) ``` And add the `SerializerExtensionsAPIViewMixin` to your API views: ```py from rest_framework.generics import RetrieveAPIView from rest_framework_serializer_extensions.views import SerializerExtensionsAPIViewMixin class RetriveOwnerAPIView(SerializerExtensionsAPIViewMixin, RetrieveAPIView): ... ``` ## Examples Serializer extensions allows your API to re-use your serializers to fit a variety of use cases. The examples shown below use query parameters to modify the response, but individual views can interact with your serializers in much the same way. ```js >>> GET /owner/x4F/ { "id": 'x4F', "name": 'tyrell', "organization_id": 'kgD' } ``` ```js >>> GET /owner/x4F/?expand=organization { "id": 'x4F', "name": 'tyrell', "organization_id": 'kgD', "organization": { "id": "kgD", "name": "E Corp" } } ``` ```js >>> GET /owner/x4F/?expand=cars__model&exclude=name { "id": 'x4F', "organization_id": 'kgD', "cars": [ { "id": "wf9", "variant": "P100D", "model": { "id": "ncX", "name": "Model S" } } ] } ``` ```js >>> GET /owner/x4F/?expand=cars&only=cars__variant { "cars": [ { "variant": "P100D", } ] } ``` ## Testing Install testing requirements. ```bash $ pip install -r requirements.txt ``` Run with runtests. ```bash $ ./runtests.py ``` You 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: ```bash $ tox ``` ## Documentation To build the documentation, you’ll need to install `mkdocs`. ```bash $ pip install mkdocs ``` To preview the documentation: ```bash $ mkdocs serve Running at: http://127.0.0.1:8000/ ``` To build the documentation: ```bash $ mkdocs build ``` [build-status-image]: https://secure.travis-ci.org/evenicoulddoit/django-rest-framework-serializer-extensions.svg?branch=master [travis]: https://secure.travis-ci.org/evenicoulddoit/django-rest-framework-serializer-extensions?branch=master [coverage-status-image]: https://img.shields.io/codecov/c/github/evenicoulddoit/django-rest-framework-serializer-extensions/master.svg [codecov]: http://codecov.io/github/evenicoulddoit/django-rest-framework-serializer-extensions?branch=master [pypi-version]: https://img.shields.io/pypi/v/djangorestframework-serializer-extensions.svg [pypi]: https://pypi.python.org/pypi/djangorestframework-serializer-extensions %prep %autosetup -n djangorestframework-serializer-extensions-2.0.1 %build %py3_build %install %py3_install install -d -m755 %{buildroot}/%{_pkgdocdir} if [ -d doc ]; then cp -arf doc %{buildroot}/%{_pkgdocdir}; fi if [ -d docs ]; then cp -arf docs %{buildroot}/%{_pkgdocdir}; fi if [ -d example ]; then cp -arf example %{buildroot}/%{_pkgdocdir}; fi if [ -d examples ]; then cp -arf examples %{buildroot}/%{_pkgdocdir}; fi pushd %{buildroot} if [ -d usr/lib ]; then find usr/lib -type f -printf "/%h/%f\n" >> filelist.lst fi if [ -d usr/lib64 ]; then find usr/lib64 -type f -printf "/%h/%f\n" >> filelist.lst fi if [ -d usr/bin ]; then find usr/bin -type f -printf "/%h/%f\n" >> filelist.lst fi if [ -d usr/sbin ]; then find usr/sbin -type f -printf "/%h/%f\n" >> filelist.lst fi touch doclist.lst if [ -d usr/share/man ]; then find usr/share/man -type f -printf "/%h/%f.gz\n" >> doclist.lst fi popd mv %{buildroot}/filelist.lst . mv %{buildroot}/doclist.lst . %files -n python3-djangorestframework-serializer-extensions -f filelist.lst %dir %{python3_sitelib}/* %files help -f doclist.lst %{_docdir}/* %changelog * Fri May 05 2023 Python_Bot - 2.0.1-1 - Package Spec generated