{ "info": { "author": "Alexander Oblovatniy", "author_email": "oblovatniy@gmail.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 5 - Production/Stable", "Intended Audience :: Developers", "License :: OSI Approved :: GNU Lesser General Public License v3 (LGPLv3)", "Natural Language :: English", "Operating System :: OS Independent", "Programming Language :: Python :: 2.7", "Programming Language :: Python :: 3.4", "Topic :: Software Development :: Libraries" ], "description": "django-rf-candv-choices\n=======================\n\n|pypi_package| |pypi_downloads| |python_versions| |license|\n\n\nUse `django-candv-choices`_ with `django-rest-framework`_.\n\n\n**Table of contents**\n\n.. contents::\n :local:\n :depth: 2\n :backlinks: none\n\n\nInstallation\n------------\n\nInstall from `PyPI `_:\n\n.. code-block:: bash\n\n $ pip install django-rf-candv-choices\n\n\nUsage\n-----\n\nSerializing choices\n~~~~~~~~~~~~~~~~~~~\n\nFor example, you have some model which uses\n``candv_x.django.choices.ChoiceField`` to store one of allowed values. This\nmight be a ``User`` model, which has ``user_role`` field, where values for\n``user_role`` are defined by ``USER_ROLES`` constants container.\n\nUse ``candv_x.rest_framework.choices.ChoiceField`` for ``user_role``\nserialization:\n\n.. code-block:: python\n\n from rest_framework import serializers\n from candv_x.rest_framework.choices import ChoiceField\n\n from .constants import USER_ROLES\n from .models import User\n\n\n class UserSerializer(serializers.ModelSerializer):\n user_role = ChoiceField(USER_ROLES)\n\n class Meta:\n model = User\n fields = ('id', 'name', 'user_role', )\n\n\n\nExposing choices to the outer world\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n\nIf you need to expose list of possible choices for your field, then you can\nuse a ``ChoicesList`` base view to get a class-based view:\n\n.. code-block:: python\n\n from candv_x.rest_framework.choices import ChoicesList\n\n from .constants import USER_ROLES\n\n\n class UserRoleList(ChoicesList):\n choices = USER_ROLES\n\nThe only thing you need to do is to define ``choices`` attribute.\n\nThere is a faster way also: you can use a ``coalitions_list`` view factory to\nget a function-based view:\n\n\n.. code-block:: python\n\n from candv_x.rest_framework.choices import simple_choices_list\n\n from .constants import USER_ROLES\n\n\n user_role_list = simple_choices_list(USER_ROLES)\n\n\nChangelog\n---------\n\n*You can click a version name to see a diff with the previous one.*\n\n* `1.0.0`_ (Aug 1, 2015)\n\n Initial version\n\n\n.. |pypi_package| image:: http://img.shields.io/pypi/v/django-rf-candv-choices.svg?style=flat\n :target: http://badge.fury.io/py/django-rf-candv-choices/\n :alt: Version of PyPI package\n\n.. |pypi_downloads| image:: http://img.shields.io/pypi/dm/django-rf-candv-choices.svg?style=flat\n :target: https://crate.io/packages/django-rf-candv-choices/\n :alt: Number of downloads of PyPI package\n\n.. |python_versions| image:: https://img.shields.io/badge/Python-2.7,3.4-brightgreen.svg?style=flat\n :alt: Supported versions of Python\n\n.. |license| image:: https://img.shields.io/badge/license-LGPLv3-blue.svg?style=flat\n :target: https://github.com/oblalex/django-rf-candv-choices/blob/master/LICENSE\n :alt: Package license\n\n\n.. _django-candv-choices: https://github.com/oblalex/django-candv-choices\n.. _django-rest-framework: http://www.django-rest-framework.org\n\n.. _1.0.0: https://github.com/oblalex/django-rf-candv-choices/releases/tag/v1.0.0\n", "description_content_type": null, "docs_url": null, "download_url": "UNKNOWN", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/oblalex/django-rf-candv-choices", "keywords": "choices,constants,candv,values,Django,rest-framework", "license": "LGPLv3", "maintainer": null, "maintainer_email": null, "name": "django-rf-candv-choices", "package_url": "https://pypi.org/project/django-rf-candv-choices/", "platform": "any", "project_url": "https://pypi.org/project/django-rf-candv-choices/", "project_urls": { "Download": "UNKNOWN", "Homepage": "https://github.com/oblalex/django-rf-candv-choices" }, "release_url": "https://pypi.org/project/django-rf-candv-choices/1.0.0/", "requires_dist": null, "requires_python": null, "summary": "Support of django-candv-choices for django-rest-framework.", "version": "1.0.0" }, "last_serial": 1660168, "releases": { "1.0.0": [ { "comment_text": "", "digests": { "md5": "1478d3e115478cfd392642a73c47ea19", "sha256": "73a5d8ffacdd6999bcb148f2fe85f6935e9fcae33f48b72d160dcbfd343e6b0c" }, "downloads": -1, "filename": "django-rf-candv-choices-1.0.0.tar.gz", "has_sig": false, "md5_digest": "1478d3e115478cfd392642a73c47ea19", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6055, "upload_time": "2015-08-01T20:06:08", "url": "https://files.pythonhosted.org/packages/4a/25/3346d41697f279607543f696cc89cab546ce9a9787d29f5ab66deda37764/django-rf-candv-choices-1.0.0.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "1478d3e115478cfd392642a73c47ea19", "sha256": "73a5d8ffacdd6999bcb148f2fe85f6935e9fcae33f48b72d160dcbfd343e6b0c" }, "downloads": -1, "filename": "django-rf-candv-choices-1.0.0.tar.gz", "has_sig": false, "md5_digest": "1478d3e115478cfd392642a73c47ea19", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6055, "upload_time": "2015-08-01T20:06:08", "url": "https://files.pythonhosted.org/packages/4a/25/3346d41697f279607543f696cc89cab546ce9a9787d29f5ab66deda37764/django-rf-candv-choices-1.0.0.tar.gz" } ] }