'Django: Leaflet map does not render when adding new item in admin inline

I am using the django-leaflet package to display the maps in the admin. I have a model that I am inserting as TabularInline, where one of the fields is a PointField.

model.py

class Occurrence(models.Model):
    name = models.CharField(max_length=254)
    location = models.PointField(null=True, blank=True)
    # .......

admin.py

class OccurrencesInline(LeafletGeoAdminMixin):
    model = Occurrence
    fields = ('name', 'location')
    show_change_link = True
    extra = 1
    formset = AtLeastOneFormSet

The map appears correctly in the extra rows that appear initially. However, when I add a new item, instead of the map, a text box appears.

Any idea why this is happening and how to fix it?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source