{"id":23579,"library":"django-map-widgets","title":"Django Map Widgets","description":"A Django library providing configurable and user-friendly map widgets for GeoDjango geometry fields. Supports Google Maps, Leaflet, and MapBox interactive maps with point, geometry, and inline formset widgets. Current version 0.5.2, released March 2025. Active development with regular releases.","status":"active","version":"0.5.2","language":"python","source_language":"en","source_url":"https://github.com/erdem/django-map-widgets","tags":["django","geodjango","maps","widgets","google-maps","leaflet","mapbox"],"install":[{"cmd":"pip install django-map-widgets","lang":"bash","label":"PyPI install"}],"dependencies":[{"reason":"GeoDjango dependency; requires django.contrib.gis","package":"Django","optional":false},{"reason":"For Leaflet interactive widgets (optional if using Google Maps or MapBox)","package":"django-leaflet","optional":true}],"imports":[{"note":"Widgets live in map_widgets.widgets module, not top-level.","wrong":"from map_widgets import GooglePointFieldWidget","symbol":"GooglePointFieldWidget","correct":"from map_widgets.widgets import GooglePointFieldWidget"},{"note":"All widget classes import from map_widgets.widgets.","wrong":"from map_widgets.mapbox import MapBoxPointFieldWidget","symbol":"MapBoxPointFieldWidget","correct":"from map_widgets.widgets import MapBoxPointFieldWidget"},{"note":"Leaflet widget also in widgets module.","wrong":"from map_widgets.leaflet import LeafletPointFieldWidget","symbol":"LeafletPointFieldWidget","correct":"from map_widgets.widgets import LeafletPointFieldWidget"},{"note":"Settings dict imported from map_widgets; not a class.","wrong":null,"symbol":"MAP_WIDGETS","correct":"from map_widgets import MAP_WIDGETS"}],"quickstart":{"code":"# settings.py\nINSTALLED_APPS = [\n    'django.contrib.gis',\n    'map_widgets',\n]\n\nMAP_WIDGETS = {\n    \"GooglePointFieldWidget\": (\n        (\"zoom\", 15),\n        (\"mapCenterLocation\", [40.7128, -74.0060]),\n        (\"GooglePlaceAutocompleteOptions\", {}),\n    ),\n    \"GoogleMaps\": {\n        \"apiKey\": os.environ.get('GOOGLE_MAPS_API_KEY', ''),\n    }\n}\n\n# models.py\nfrom django.contrib.gis.db import models\nclass Location(models.Model):\n    point = models.PointField()\n    address = models.CharField(max_length=255)\n\n# admin.py\nfrom django.contrib.gis import admin\nfrom .models import Location\nfrom map_widgets.widgets import GooglePointFieldWidget\n\nclass LocationAdmin(admin.GISModelAdmin):\n    list_display = ('address',)\n    formfield_overrides = {\n        models.PointField: {\"widget\": GooglePointFieldWidget}\n    }\n\nadmin.site.register(Location, LocationAdmin)","lang":"python","description":"Basic setup for Google Maps point widget; replace API key via environment variable."},"warnings":[{"fix":"Replace MAP_WIDGETS = {'GooglePointFieldWidget': (('zoom', 15),)} and API key under 'GoogleMaps' key.","message":"v0.5.0 introduced a new settings structure. Old settings like GOOGLE_MAP_API_KEY no longer work; use MAP_WIDGETS dict instead.","severity":"breaking","affected_versions":"<0.5.0"},{"fix":"Ensure custom widget get_context() calls super().get_context(attname, ...) and re-add id/name if needed.","message":"v0.5.2 removed `id` and `name` from template context in BaseGeometryWidget.get_context() for Django 6.0 compatibility. If you override get_context(), you must call super() and handle context.","severity":"breaking","affected_versions":">=0.5.2"},{"fix":"Use new structure inside MAP_WIDGETS['GooglePointFieldWidget'] tuple.","message":"GooglePlaceAutocompleteOptions settings have changed. Old 'autocomplete' key may be ignored.","severity":"deprecated","affected_versions":">=0.5.0"},{"fix":"Ensure 'django.contrib.gis' is in INSTALLED_APPS and GDAL library is installed.","message":"Missing django.contrib.gis in INSTALLED_APPS or GDAL not installed causes silent failures.","severity":"gotcha","affected_versions":"all"},{"fix":"Upgrade to 0.5.1+ or manually copy static files.","message":"When using ManifestStaticFilesStorage, run collectstatic after installation. v0.5.1 fixed a bug that caused errors during collectstatic.","severity":"gotcha","affected_versions":"<0.5.1"}],"env_vars":null,"last_verified":"2026-05-01T00:00:00.000Z","next_check":"2026-07-30T00:00:00.000Z","problems":[{"fix":"Add 'django.contrib.gis' to INSTALLED_APPS and ensure GDAL is installed.","cause":"Missing 'django.contrib.gis' in INSTALLED_APPS.","error":"django.core.exceptions.ImproperlyConfigured: django.contrib.gis is not installed"},{"fix":"Define MAP_WIDGETS in settings.py with at least one provider configuration.","cause":"MAP_WIDGETS settings dict is missing or misconfigured.","error":"AttributeError: 'NoneType' object has no attribute 'items'"},{"fix":"Run pip install django-map-widgets and ensure virtual env is activated.","cause":"Package not installed or not in virtual environment.","error":"ModuleNotFoundError: No module named 'map_widgets'"}],"ecosystem":"pypi","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}