{"id":31846853,"url":"https://github.com/frojd/restframework-gis-distance","last_synced_at":"2026-03-02T18:41:34.332Z","repository":{"id":57421635,"uuid":"51147041","full_name":"Frojd/restframework-gis-distance","owner":"Frojd","description":"This is a extension to Django-Rest-Framework-Gis that adds sorting by distance and distance units.","archived":false,"fork":false,"pushed_at":"2019-01-27T13:04:40.000Z","size":15,"stargazers_count":12,"open_issues_count":3,"forks_count":3,"subscribers_count":4,"default_branch":"develop","last_synced_at":"2025-09-22T14:20:16.838Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Frojd.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-02-05T13:08:26.000Z","updated_at":"2024-11-03T18:11:43.000Z","dependencies_parsed_at":"2022-09-01T04:53:26.907Z","dependency_job_id":null,"html_url":"https://github.com/Frojd/restframework-gis-distance","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/Frojd/restframework-gis-distance","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Frojd%2Frestframework-gis-distance","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Frojd%2Frestframework-gis-distance/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Frojd%2Frestframework-gis-distance/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Frojd%2Frestframework-gis-distance/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Frojd","download_url":"https://codeload.github.com/Frojd/restframework-gis-distance/tar.gz/refs/heads/develop","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Frojd%2Frestframework-gis-distance/sbom","scorecard":{"id":53133,"data":{"date":"2025-08-11","repo":{"name":"github.com/Frojd/restframework-gis-distance","commit":"cbda8ecbc8c8a20a826547dbf04de179e57aef73"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":3,"checks":[{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"Pinned-Dependencies","score":-1,"reason":"no dependencies found","details":null,"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"Dangerous-Workflow","score":-1,"reason":"no workflows found","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"Code-Review","score":0,"reason":"Found 0/12 approved changesets -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Maintained","score":0,"reason":"0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"Token-Permissions","score":-1,"reason":"No tokens found","details":null,"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"SAST","score":0,"reason":"no SAST tool detected","details":["Warn: no pull requests merged into dev branch"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"Vulnerabilities","score":10,"reason":"0 existing vulnerabilities detected","details":null,"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: LICENSE:0","Info: FSF or OSI recognized license: MIT License: LICENSE:0"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"Branch-Protection","score":0,"reason":"branch protection not enabled on development/release branches","details":["Warn: branch protection not enabled for branch 'develop'"],"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}}]},"last_synced_at":"2025-08-15T00:06:59.319Z","repository_id":57421635,"created_at":"2025-08-15T00:06:59.319Z","updated_at":"2025-08-15T00:06:59.319Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279010970,"owners_count":26084837,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-10-12T02:00:06.719Z","response_time":53,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-10-12T09:17:22.097Z","updated_at":"2025-10-12T09:17:24.528Z","avatar_url":"https://github.com/Frojd.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![Build Status](https://travis-ci.org/Frojd/restframework-gis-distance.svg?branch=master)](https://travis-ci.org/Frojd/restframework-gis-distance)\n\n# Django-Rest-Framework-Gis-Distance\n\nThis is a extension to [Django-Rest-Framework-Gis](https://github.com/djangonauts/django-rest-framework-gis) that adds sorting and distance distance to the [DistanceToPointerFilter](https://github.com/djangonauts/django-rest-framework-gis#distancetopointfilter).\n\n\n## Requirements\n\n- Python 2.7\n- Django 1.7+\n- Django-Rest-Framework-Gis 0.10+\n\n\n## Installation\n\nInstall the library with pip:\n\n```\n$ pip install djangorestframework-gis-distance\n```\n\n\n## Quick Setup\n\nMake sure `rest_framework_gis_distance` is added to your `INSTALLED_APPS`, after `rest_framework` and `restframework_gis`.\n\n```python\nINSTALLED_APPS = (\n    # ...\n\n    'rest_framework',\n    'rest_framework_gis',\n    'rest_framework_gis_distance',\n)\n```\n\n\n## Usage\n\n\n### Regular implementation\n\nFirst include DistanceField in your serializer.\n\n```python\nfrom restframework_gis_distance.fields import DistanceField\n\nclass RecordSerializer(serializers.ModelSerializer):\n    distance = DistanceField(unit='m')\n\n    class Meta:\n        model = Record\n        fields = ('location', 'title', 'created', 'distance')\n```\n\n\nThen use the filter `OrderedDistanceToPointFilter` in your view.\n\n```python\nfrom restframework_gis_distance.filters import OrderedDistanceToPointFilter\n\nclass 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```\n\nAfter this, set up your urls as usual and call your endpoint like this:\n`example.com/api/endpoint/?dist=1000\u0026point=long,lat`\n\n\n### Optional field\n\nUsing distance as a optional field (for the cases when you only want to display distance when geo coordinates is supplied)\n\nInstead of declaring a straight DistanceField, wrap the DistanceField as a SerializerMethodField, like this:\n\n```python\nfrom restframework_gis_distance.filters import OrderedDistanceToPointFilter\n\nclass 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```\n\n## Options\n\n### These belong in your DRF view:\n\n- `distance_filter_field`: Target geo filtering field (inherited from DistanceToPointerFilter).\n- `distance_srid`: (Optional) The srid you want to use on your distance. (Default `4326`)\n- `distance_sort_order`: (Optional) Indicates the sort order, closest (`True`) or farthest (`False`). (Default: `True`) \n\n\n## Questions\n- How do I change distance unit?\n\t- Add the param unit=DESIRED_UNIT to your DistanceField, make sure you use a [django supported unit](https://docs.djangoproject.com/en/1.9/ref/contrib/gis/measure/#supported-units).\n\n\n## Tests\n\nThis library include tests, just run `python runtests.py`.\n\n\n## Contributing\n\nWant to contribute? Awesome. Just send a pull request.\n\n\n## License\n\nDjango-Rest-Framework-Gis-Distance is released under the [MIT License](http://www.opensource.org/licenses/MIT).\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffrojd%2Frestframework-gis-distance","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffrojd%2Frestframework-gis-distance","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffrojd%2Frestframework-gis-distance/lists"}