{"id":17172881,"url":"https://github.com/20tab/django-political-map","last_synced_at":"2025-04-13T16:12:49.615Z","repository":{"id":18401379,"uuid":"82464593","full_name":"20tab/django-political-map","owner":"20tab","description":"Django Political Map","archived":false,"fork":false,"pushed_at":"2022-12-08T01:26:41.000Z","size":154,"stargazers_count":11,"open_issues_count":5,"forks_count":2,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-04-13T16:12:44.559Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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/20tab.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":"2017-02-19T14:25:18.000Z","updated_at":"2024-05-09T16:27:37.000Z","dependencies_parsed_at":"2023-01-13T19:48:46.864Z","dependency_job_id":null,"html_url":"https://github.com/20tab/django-political-map","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/20tab%2Fdjango-political-map","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/20tab%2Fdjango-political-map/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/20tab%2Fdjango-political-map/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/20tab%2Fdjango-political-map/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/20tab","download_url":"https://codeload.github.com/20tab/django-political-map/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248741195,"owners_count":21154255,"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","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":"2024-10-14T23:48:35.493Z","updated_at":"2025-04-13T16:12:49.564Z","avatar_url":"https://github.com/20tab.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![Build Status](https://travis-ci.org/20tab/django-political-map.svg?branch=master)](https://travis-ci.org/20tab/django-political-map)\n\nDjango Political Map\n====================\n\nDjango application to store geolocalized places and organize them\naccording to political hierarchy.\n\nNote: this project doesn't require GeoDjango or Gis fields, you should save\ngeographical data in your own model in order to perform gis queries.\n\nFeatures:\n- store your geographic data in a single model\n- provide address and process it to automatically fill all geo informations\n- using the provided form you can choose the place on the map\n- and process automatically the location\n\nInstallation\n------------\nThis package looks stable but it needs more live testing.\nIf you want to try it in your project, you can pip install it:\n\n  - ```pip install django-political-map```\n\n  or via git:\n\n  - ```pip install git+https://github.com/20tab/django-political-map.git```\n  \n  - add ```politicalplaces``` in your INSTALLED_APPS\n  \n  - set mandatory parameters in your settings file:\n```python\n# BACKEND (googlemaps is the only available backend)\nPOLITICAL_MAP_BACKEND = 'googlemaps'\n# MAP LANGUAGE (en is the only available language)\nPOLITICAL_MAP_LANGUAGE_CODE = 'en'\n# GMAPS (gmaps key is mandatory)\nGOOGLE_API_KEY = \"xxxxxxxxxxxxxxxx\"\n```\n  \n  - run migrations to update your db **python manage.py migrate**\n  \n  - manage static files using:\n    - django **collectstatic** or  \n    - uwsgi **static-map = /static/politicalplaces/=%(lib)/politicalplaces/static/politicalplaces**\n    \n\nHow to\n------\nThere is one only entry point to the app, that is the **Placefield**.\nThis field is a Foreign Key to PoliticalPlace, so you should use it \nthis way:\n```python\nfrom django.db import models                                                \nfrom politicalplaces.fields import PlaceField\n\n\nclass MyLocation(models.Model):\n    place = PlaceField(\n        on_delete=models.SET_NULL,\n        null=True, blank=True)\n```\nPoliticalPlace and MapItem admin are available, but you should never add\nthese objects directly.\n\nUsing PoliticalPlace in the views\n---------------------------------\n```python\nfrom politicalplaces.models import PoliticalPlace\nfrom .models import MyLocation\n\n\nloc = MyLocation()\nloc.name = \"Test Location\"\nplace = PoliticalPlace.get_or_create_from_address(\n    address='via Luigi Gastinelli, Rome')\nloc.place = place\nloc.save()\n```\n\nRefresh Data (django command)\n-----------------------------\n```\n(django-political-map) 20tab:django-political-map gabbo$ python manage.py refresh_data --help\nusage: manage.py refresh_data [-h] [--version] [-v {0,1,2,3}]\n                              [--settings SETTINGS] [--pythonpath PYTHONPATH]\n                              [--traceback] [--no-color]\n                              [place_id [place_id ...]]\n\nRefresh map data calling the external api\n\npositional arguments:\n  place_id              The id list, separeted by space, of the involved\n                        PoliticalPlace objects.\n\noptional arguments:\n  -h, --help            show this help message and exit\n  --version             show program's version number and exit\n  -v {0,1,2,3}, --verbosity {0,1,2,3}\n                        Verbosity level; 0=minimal output, 1=normal output,\n                        2=verbose output, 3=very verbose output\n  --settings SETTINGS   The Python path to a settings module, e.g.\n                        \"myproject.settings.main\". If this isn't provided, the\n                        DJANGO_SETTINGS_MODULE environment variable will be\n                        used.\n  --pythonpath PYTHONPATH\n                        A directory to add to the Python path, e.g.\n                        \"/home/djangoprojects/myproject\".\n  --traceback           Raise on CommandError exceptions\n  --no-color            Don't colorize the command output.\n\n(django-political-map) 20tab:django-political-map gabbo$ python manage.py refresh_data 2\nRefresh data started.\nRefreshing data for PoliticalPlace: 2 - Brisbane QLD, Australia\nRefresh data completed successfully  for 1 items, 0 errors.\n\n(django-political-map) 20tab:django-political-map gabbo$ python manage.py refresh_data 2 3 4\nRefresh data started.\nRefreshing data for PoliticalPlace: 2 - Brisbane QLD, Australia\nRefreshing data for PoliticalPlace: 3 - Via Luigi Gastinelli, 118, 00132 Roma RM, Italy\nRefreshing data for PoliticalPlace: 4 - US-3, United States\nRefresh data completed successfully for 3 items, 0 errors.\n\n(django-political-map) 20tab:django-political-map gabbo$ python manage.py refresh_data 2 3 4 -v 0\nRefresh data started.\nRefresh data completed successfully for 3 items, 0 errors.\n\n(django-political-map) 20tab:django-political-map gabbo$ python manage.py refresh_data\nRefresh data started.\nRefreshing data for PoliticalPlace: 2 - Brisbane QLD, Australia\nRefreshing data for PoliticalPlace: 3 - Via Luigi Gastinelli, 118, 00132 Roma RM, Italy\n[...]\nRefreshing data for PoliticalPlace: 28 - Čerpadlová 572/5, Vysočany, 190 00 Praha-Praha 9, Czechia\nRefresh data completed successfully for 27 items, 0 errors.\n```\n\nJavascript Initialization\n--------------------------\nDjango Political Map has full support for admin change_form with\nsingle PlaceField, multiple PlaceField on the same model and\ninline models with PlaceField.\n\nThe default widget will work on your custom frontend too (just remember to\nuse {{forms.media}} in your template).\n\nThe library also supports django inline formsets via the `formset:added`\nevent if using `django.jQuery` (\"admin/js/vendor/jquery/jquery.js\", \"admin/js/jquery.init.js\"),\notherwise you can attach to your custom event the\n`politicalplaces.addNewWidget(widgetDOMElement, formsetName)` handler. \nExample:\n```\ndocument.querySelector('button.add-form').addEventListener('click', function() {\n  var formsetName = 'the_name_of_the_formset';\n  var widgetDOMElement = document.querySelector('.widget');\n  politicalplaces.addNewWidget(widgetDOMElement, formsetName);\n});\n```\n\n\nGMAPS quota limit\n-----------------\nUsing googlemaps as backend, remember there's a quota limit\nas described here: https://developers.google.com/maps/documentation/javascript/usage\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2F20tab%2Fdjango-political-map","html_url":"https://awesome.ecosyste.ms/projects/github.com%2F20tab%2Fdjango-political-map","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2F20tab%2Fdjango-political-map/lists"}