2

How can I enter the latitude and longitude of a PointField when creating/editing an entry using the OSMGeoAdmin or GeoModelAdmin? Currently, I have a map where I can place the point by clicking on the map. I'd like to keep this behavior but also be able to manually specify the exact values.

Editing point field with OSMGeoAdmin

Details

I have a Location model with a PointField attribute.

# models.py
class Location(models.Model):
    name = models.CharField(max_length=255, db_index=True)
    point = PointField(blank=True, null=True)
# admin.py
from django.contrib.gis.admin import OSMGeoAdmin

@admin.register(Location)
class LocationAdmin(OSMGeoAdmin):
    list_display = ("id", "name")
nbeuchat
  • 6,575
  • 5
  • 36
  • 50

1 Answers1

0

I was able to do so using LeafletGeoAdmin.

# admin.py
from leaflet.admin import LeafletGeoAdmin

@admin.register(Location)
class LocationAdmin(LeafletGeoAdmin):
    list_display = ("id", "name")
    settings_overrides = {
       'DEFAULT_CENTER': (49.474182, 10.988509),
       'DEFAULT_ZOOM': 15,
    }
    display_raw = True
Dharman
  • 30,962
  • 25
  • 85
  • 135
vchrisb
  • 23
  • 5