Displaying a map in a Django Webapp (3/3): Showing a map on the Django admin

Hakim Benoudjit
1 min readApr 8, 2018

--

We need to configure the Django’s admin section to be able to visualize the cities table entries there (see the previous tutorial). First of all, we will need to create a superuser that can be used to login to localhost:8000/admin:

Then, we edit the content of “cities/admin.py” the same way it was done on the leaflet docs. In the piece of code below, we’re overriding the class LeafletGeoAdmin to get annotated OpenStreetMap in the backend. Eventually, the app is registered on the admin section on the last line of this file.

Each city can be visualized on the Django backend by browsing to “localhost:8000/admin/cities/city/<id>”:

Don’t forget to clap if this story has been useful to you.

--

--