{ "info": { "author": "Fr\u00f6jd", "author_email": "martin@marteinn.se", "bugtrack_url": null, "classifiers": [ "Development Status :: 4 - Beta", "Environment :: Web Environment", "Framework :: Django", "Intended Audience :: Developers", "License :: OSI Approved :: MIT License", "Natural Language :: English", "Programming Language :: Python", "Programming Language :: Python :: 2", "Programming Language :: Python :: 2.7", "Topic :: Utilities" ], "description": "|Build Status|\n\nDjango-Rest-Framework-Gis-Distance\n==================================\n\nThis is a extension to\n`Django-Rest-Framework-Gis `__\nthat adds sorting and distance distance to the\n`DistanceToPointerFilter `__.\n\nRequirements\n------------\n\n- Python 2.7\n- Django 1.7+\n- Django-Rest-Framework-Gis 0.10+\n\nInstallation\n------------\n\nInstall the library with pip:\n\n::\n\n $ pip install djangorestframework-gis-distance\n\nQuick Setup\n-----------\n\nMake sure ``rest_framework_gis_distance`` is added to your\n``INSTALLED_APPS``, after ``rest_framework`` and ``restframework_gis``.\n\n.. code:: python\n\n INSTALLED_APPS = (\n # ...\n\n 'rest_framework',\n 'rest_framework_gis',\n 'rest_framework_gis_distance',\n )\n\nUsage\n-----\n\nRegular implementation\n~~~~~~~~~~~~~~~~~~~~~~\n\nFirst include DistanceField in your serializer.\n\n.. code:: python\n\n from restframework_gis_distance.fields import DistanceField\n\n class RecordSerializer(serializers.ModelSerializer):\n distance = DistanceField(unit='m')\n\n class Meta:\n model = Record\n fields = ('location', 'title', 'created', 'distance')\n\nThen use the filter ``OrderedDistanceToPointFilter`` in your view.\n\n.. code:: python\n\n from restframework_gis_distance.filters import OrderedDistanceToPointFilter\n\n class RecordListView(mixins.ListModelMixin, generics.GenericAPIView):\n permission_classes = (AllowAny,)\n serializer_class = RecordSerializer\n queryset = Record.objects.all()\n filter_backends = (OrderedDistanceToPointFilter,)\n distance_filter_field = 'location'\n distance_filter_convert_meters = True\n distance_filter_add_distance = True\n\nAfter this, set up your urls as usual and call your endpoint like this:\n``example.com/api/endpoint/?dist=1000&point=long,lat``\n\nOptional field\n~~~~~~~~~~~~~~\n\nUsing distance as a optional field (for the cases when you only want to\ndisplay distance when geo coordinates is supplied)\n\nInstead of declaring a straight DistanceField, wrap the DistanceField as\na SerializerMethodField, like this:\n\n.. code:: python\n\n from restframework_gis_distance.filters import OrderedDistanceToPointFilter\n\n class RecordOptionalSerializer(serializers.ModelSerializer):\n distance = serializers.SerializerMethodField()\n\n class Meta:\n model = Record\n fields = ('location', 'title', 'created', 'distance')\n\n def get_distance(self, obj):\n distance = getattr(obj, \"distance\", None)\n return DistanceField(unit='m').to_representation(distance)\n\nOptions\n-------\n\nThese belong in your DRF view:\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n\n- ``distance_filter_field``: Target geo filtering field (inherited from\n DistanceToPointerFilter).\n- ``distance_srid``: (Optional) The srid you want to use on your\n distance. (Default ``4326``)\n- ``distance_sort_order``: (Optional) Indicates the sort order, closest\n (``True``) or farthest (``False``). (Default: ``True``)\n\nQuestions\n---------\n\n- How do I change distance unit?\n\n - Add the param unit=DESIRED\\_UNIT to your DistanceField, make sure\n you use a `django supported\n unit `__.\n\nTests\n-----\n\nThis library include tests, just run ``python runtests.py``.\n\nContributing\n------------\n\nWant to contribute? Awesome. Just send a pull request.\n\nLicense\n-------\n\nDjango-Rest-Framework-Gis-Distance is released under the `MIT\nLicense `__.\n\n.. |Build Status| image:: https://travis-ci.org/Frojd/restframework-gis-distance.svg?branch=master\n :target: https://travis-ci.org/Frojd/restframework-gis-distance", "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/Frojd/restframework-gis-distance", "keywords": null, "license": "MIT", "maintainer": null, "maintainer_email": null, "name": "djangorestframework-gis-distance", "package_url": "https://pypi.org/project/djangorestframework-gis-distance/", "platform": "UNKNOWN", "project_url": "https://pypi.org/project/djangorestframework-gis-distance/", "project_urls": { "Download": "UNKNOWN", "Homepage": "https://github.com/Frojd/restframework-gis-distance" }, "release_url": "https://pypi.org/project/djangorestframework-gis-distance/1.0.0/", "requires_dist": null, "requires_python": null, "summary": "UNKNOWN", "version": "1.0.0" }, "last_serial": 1944545, "releases": { "1.0.0": [ { "comment_text": "", "digests": { "md5": "083063c4816ceb782df1c7a4f61cb5d5", "sha256": "e2c9f643b02d0c43407cbb2b4a6f5f140a30fe61d1baa407deddfefa30926798" }, "downloads": -1, "filename": "djangorestframework-gis-distance-1.0.0.tar.gz", "has_sig": false, "md5_digest": "083063c4816ceb782df1c7a4f61cb5d5", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5517, "upload_time": "2016-02-07T19:04:59", "url": "https://files.pythonhosted.org/packages/54/83/496719d20ec65ae1b4c4e6dcc72c13ef6683ec7036d2573f16fc6073d277/djangorestframework-gis-distance-1.0.0.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "083063c4816ceb782df1c7a4f61cb5d5", "sha256": "e2c9f643b02d0c43407cbb2b4a6f5f140a30fe61d1baa407deddfefa30926798" }, "downloads": -1, "filename": "djangorestframework-gis-distance-1.0.0.tar.gz", "has_sig": false, "md5_digest": "083063c4816ceb782df1c7a4f61cb5d5", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5517, "upload_time": "2016-02-07T19:04:59", "url": "https://files.pythonhosted.org/packages/54/83/496719d20ec65ae1b4c4e6dcc72c13ef6683ec7036d2573f16fc6073d277/djangorestframework-gis-distance-1.0.0.tar.gz" } ] }