Search code examples
djangogisadmingeodjango

Django does not load the maps in the admin panel


I need to upgrade the Django version of a project that uses GeoModelAdmin for displaying maps in the admin panel. The recommended class to be used is ModelAdmin as stated in the documentation:

Deprecated since version 4.0: This class is deprecated. Use ModelAdmin instead.

However, when I use ModelAdmin the maps do not load at all. And I get this error in the console:

GET https://gitc.earthdata.nasa.gov/wmts/epsg3857/best/BlueMarble_ShadedRelief_Bathymetry/default/%7BTime%7D/GoogleMapsCompatible_Level8/8/92/146.jpg 500 (Internal Server Error)

Is there a configuration that I missed or there are problems with the server?

In the past I used OSMGeoAdmin which was exactly what I needed, but got it deprecated in Django 4.0. Now is suggested to use GISModelAdmin instead. When I use GISModelAdmin the maps are loaded, but I want to configure the zoom level and if I set the gis_widget_kwargs according to the documentation, nothing changes.

    gis_widget_kwargs = {
        "attrs": {
            "default_lon": 5,
            "default_lat": 47,
            "default_zoom": 3,
        }
    }

This happens with Django 4.2 and Python 3.12.

Later edit:

# models.py
class LandField(PostgresModel)
  shape = models.PolygonField(geography=True)
# admin.py
class LandFieldAdmin(admin.ModelAdmin):
  list_display = ...

Solution

  • There was a temporary problem with the NASA servers that provided the map for the Django Admin widget. The widget works as expected now.