{ "info": { "author": "Craig Tweedy", "author_email": "ahoy@craigtweedy.co.uk", "bugtrack_url": null, "classifiers": [ "Development Status :: 4 - Beta", "Environment :: Web Environment", "Framework :: Django", "Intended Audience :: Developers", "License :: OSI Approved :: MIT License", "Operating System :: OS Independent", "Programming Language :: Python", "Programming Language :: Python :: 3", "Topic :: Internet :: WWW/HTTP" ], "description": "# Simple versioning for [Django REST framework][docs]\n\n[![pypi-version]][pypi]\n\n# Overview\n\nDjango Rest Framework provides the ability to version an API via multiple methods, namespacing the URL, adding a version to the Accept header or query parameter, and provides this version to your code. However, it doesn't go further than this in helping split up what code is ran based on this version, leaving this a task up to the developer.\n\nThis mixin allows the developer to set which class is ran depending on what version is passed to the API, without interferring with how DRF generic views work.\n\n# Requirements\n\n* Python 2.7+\n* Django Rest Framework 3.1+\n\n# Installation\n\nInstall using `pip`...\n\n pip install djangorestversioning\n\n# Example\n\nMake sure you're using a versioning class in your `settings.py` (Rest Framework does not default to any versioning class)\n\n```python\n\nREST_FRAMEWORK = {\n\t'DEFAULT_VERSIONING_CLASS': 'rest_framework.versioning.AcceptHeaderVersioning'\n}\n\n```\n\nEnsure you're using namespacing on your endpoints\n\n```python\n\nurlpatterns = patterns(\n '',\n url(r'^api/', include(patterns(\n '',\n url(r'^items/', include('items.urls')),\n ), namespace='1.0')),\n)\n\n```\n\nYou wire up your generic view URL's in the same way as before:\n\n```python\nfrom django.conf.urls import url\nfrom items.views import ItemList\n\n# Wire up your API using generic views\nurlpatterns = [\n url(r'^items/$', ItemList.as_view())\n]\n```\n\nEnsure the resulting generic view has the versioning mixin, and that you provide a versions dictionary detailing where each version of the endpoint exists.\n\n```python\n\nfrom djangorestversioning.versioning import VersionedEndpoint\n\nclass ItemList(VersionedEndpoint, APIView):\n\t\"\"\"\n\tList all items.\n\t\"\"\"\n\tversions = {\n\t\t1.0 : 'api.v1.items.ItemList',\n\t\t2.0 : 'api.v2.items.ItemList'\n\t}\n```\n\nEach version of the endpoint can now do what it needs to do per version\n\n```python\n\n# v1\nclass ItemList(ListAPIView):\n\t\"\"\"\n\tList all items for v1.\n\t\"\"\"\n serializer_class = ItemSerializer\n\tqueryset = Item.objects.all()\n```\n\n```python\n\n# v2\nclass ItemList(ListCreateAPIView):\n\t\"\"\"\n\tList all items for v2, enable creation on v2\n\t\"\"\"\n serializer_class = ItemSerializer\n\tqueryset = Item.objects.all()\n```\n\n# Considerations\n\nIf you request a version which does not have a corresponding entry in the versions dictionary, the dispatcher will select the latest version available by running `max` on the keys of the versions. This requires that keys in the dictionary are numerical, and ordered. This could be improved upon in the future.\n\nIf a module or class is not found, an `ImportError` or `AttributeError` will be raised.\n\n[pypi-version]: https://img.shields.io/pypi/v/djangorestversioning.svg\n[pypi]: https://pypi.python.org/pypi/djangorestversioning\n\n\n[docs]: http://www.django-rest-framework.org/\n", "description_content_type": null, "docs_url": null, "download_url": "https://github.com/craigtweedy/django-rest-versioning/tarball/0.2.3", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/craigtweedy/django-rest-versioning", "keywords": "django,django-rest-framework,version,versioning,api", "license": "MIT", "maintainer": null, "maintainer_email": null, "name": "djangorestversioning", "package_url": "https://pypi.org/project/djangorestversioning/", "platform": "UNKNOWN", "project_url": "https://pypi.org/project/djangorestversioning/", "project_urls": { "Download": "https://github.com/craigtweedy/django-rest-versioning/tarball/0.2.3", "Homepage": "https://github.com/craigtweedy/django-rest-versioning" }, "release_url": "https://pypi.org/project/djangorestversioning/0.2.3/", "requires_dist": null, "requires_python": null, "summary": "A lightweight mixin to allow routing Django Rest Framework endpoints to different classes depending on version.", "version": "0.2.3" }, "last_serial": 1814683, "releases": { "0.2.1": [ { "comment_text": "", "digests": { "md5": "3dea3331a35f563f4851502397291aaa", "sha256": "8883078b6461103a0e6e5397997dbdbd51eaaaed44d84b1fd9eada9fa1e094bd" }, "downloads": -1, "filename": "djangorestversioning-0.2.1.tar.gz", "has_sig": false, "md5_digest": "3dea3331a35f563f4851502397291aaa", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 1508, "upload_time": "2015-11-12T15:38:48", "url": "https://files.pythonhosted.org/packages/e1/9a/f2419c916c9655ca1694115ec93706890febd00a1ba0dae0aeae951a4b99/djangorestversioning-0.2.1.tar.gz" } ], "0.2.2": [ { "comment_text": "", "digests": { "md5": "9ac4e534035d59abe1db660cab8481c5", "sha256": "040995f8d6635bbff2fdc896e90856b3a968ccd068eee217b870f761a22880fc" }, "downloads": -1, "filename": "djangorestversioning-0.2.2.tar.gz", "has_sig": false, "md5_digest": "9ac4e534035d59abe1db660cab8481c5", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 3562, "upload_time": "2015-11-12T18:43:45", "url": "https://files.pythonhosted.org/packages/f7/2d/ce0ca0c7a670e54d788116e8d1b352453df1b449b6d94238e63034fbd4d6/djangorestversioning-0.2.2.tar.gz" } ], "0.2.3": [ { "comment_text": "", "digests": { "md5": "0ae05bb3a28f1950b32787bff472cd80", "sha256": "e993ef4c65ee215ddf73205dd2f84ac84e50c3e8dc501b0a3ba36e7fbf47d994" }, "downloads": -1, "filename": "djangorestversioning-0.2.3.tar.gz", "has_sig": false, "md5_digest": "0ae05bb3a28f1950b32787bff472cd80", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 3573, "upload_time": "2015-11-13T11:45:12", "url": "https://files.pythonhosted.org/packages/7d/4f/f72000c8d535e7b3cee315b5fd25dc1d0a3ad7a0ae6b1d777ca9a6ae97e5/djangorestversioning-0.2.3.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "0ae05bb3a28f1950b32787bff472cd80", "sha256": "e993ef4c65ee215ddf73205dd2f84ac84e50c3e8dc501b0a3ba36e7fbf47d994" }, "downloads": -1, "filename": "djangorestversioning-0.2.3.tar.gz", "has_sig": false, "md5_digest": "0ae05bb3a28f1950b32787bff472cd80", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 3573, "upload_time": "2015-11-13T11:45:12", "url": "https://files.pythonhosted.org/packages/7d/4f/f72000c8d535e7b3cee315b5fd25dc1d0a3ad7a0ae6b1d777ca9a6ae97e5/djangorestversioning-0.2.3.tar.gz" } ] }