{"id":21152,"library":"django-leaflet","title":"django-leaflet","description":"django-leaflet provides a Django map widget for displaying and editing OpenStreetMap / Leaflet maps in admin and front-end forms. Version 0.33.0 supports Python >=3.10, Leaflet 1.7+. Release cadence: occasional, with last release in 2024.","status":"active","version":"0.33.0","language":"python","source_language":"en","source_url":"https://github.com/makinacorpus/django-leaflet","tags":["django","leaflet","gis","map","widget","admin"],"install":[{"cmd":"pip install django-leaflet","lang":"bash","label":"pip"}],"dependencies":[{"reason":"Required: Django map widget","package":"django","optional":false}],"imports":[{"note":"LeafletWidget is in forms.widgets submodule.","wrong":"from leaflet import LeafletWidget","symbol":"LeafletWidget","correct":"from leaflet.forms.widgets import LeafletWidget"},{"note":"No contrib module; admin is top-level under leaflet.","wrong":"from leaflet.contrib.admin import LeafletGeoAdmin","symbol":"LeafletGeoAdmin","correct":"from leaflet.admin import LeafletGeoAdmin"},{"note":"display_messages is a function inside forms.widgets, not top-level.","wrong":"from leaflet import display_messages","symbol":"display_messages","correct":"from leaflet.forms.widgets import display_messages"}],"quickstart":{"code":"INSTALLED_APPS = [\n    'leaflet',\n    'django.contrib.gis',\n    # ...\n]\n\nLEAFLET_CONFIG = {\n    'DEFAULT_CENTER': (51.5, -0.09),\n    'DEFAULT_ZOOM': 5,\n    'MIN_ZOOM': 3,\n    'MAX_ZOOM': 18,\n}\n\n# In your admin.py:\nfrom leaflet.admin import LeafletGeoAdmin\nfrom django.contrib.gis import admin\n\nclass LocationAdmin(LeafletGeoAdmin):\n    pass\n\nadmin.site.register(Location, LocationAdmin)","lang":"python","description":"Add 'leaflet' to INSTALLED_APPS, configure LEAFLET_CONFIG, then use LeafletGeoAdmin for your GIS model admin."},"warnings":[{"fix":"Update Django to 3.2+ or use django-leaflet==0.28.2.","message":"django-leaflet dropped support for Django <3.2 in version 0.29.0. If upgrading from an older version, ensure Django >=3.2 or pin to 0.28.x.","severity":"breaking","affected_versions":">=0.29.0"},{"fix":"Update your LEAFLET_CONFIG tiles to 'https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png'.","message":"Leaflet 1.0+ changed tile layer URLs; default OSM tile URL changed from http to https. If you override tiles via LEAFLET_CONFIG, ensure you use protocol-relative or https URLs.","severity":"breaking","affected_versions":">=0.30.0 (Leaflet 1.7+)"},{"fix":"Use forms.PointField(widget=LeafletWidget()) in your form or model form.","message":"LeafletWidget displays a map but does not handle form submission validation for geometry fields. You must use a GeoDjango form field (e.g., PointField, PolygonField) in your form; LeafletWidget is just the rendering widget.","severity":"gotcha","affected_versions":"all"},{"fix":"Replace 'from leaflet.extras import LeafletGeoAdmin' with 'from leaflet.admin import LeafletGeoAdmin'.","message":"The 'leaflet.extras' module (ExtraAdminMixin, etc.) is deprecated in favor of directly using LeafletGeoAdmin or custom admin. It may be removed in a future release.","severity":"deprecated","affected_versions":">=0.30.0"}],"env_vars":null,"last_verified":"2026-04-27T00:00:00.000Z","next_check":"2026-07-26T00:00:00.000Z","problems":[{"fix":"Use: from leaflet.forms.widgets import LeafletWidget","cause":"Incorrect import path; LeafletWidget is in leaflet.forms.widgets, not top-level leaflet.","error":"ImportError: cannot import name 'LeafletWidget' from 'leaflet'"},{"fix":"Add 'django.contrib.gis' to INSTALLED_APPS in your Django settings.","cause":"django-leaflet requires django.contrib.gis to be installed.","error":"django.core.exceptions.ImproperlyConfigured: 'django.contrib.gis' is not in INSTALLED_APPS"}],"ecosystem":"pypi","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}