I'm trying to set the default value of a django.contrib.gis.forms.PointField
in my django admin with a customized form like this:
from django.contrib.gis import forms
from django.contrib.gis.geos import Point
from api import models
class CustomPlaceCreationForm(forms.ModelForm):
place_url = forms.CharField(initial="https://www.places.com/myplace")
position = forms.PointField(
widget=forms.OSMWidget(attrs={'map_width': 800, 'map_height': 500}),
initial=Point(x=121.502020, y=25.039270, srid=4326)
)
class Meta:
model = models.Place
fields = '__all__'
The place_url
initial
works perfectly but the position
is always [0, 0]
by default.
Is it a bug from the library or something I'm not doing correctly? Any workaround? Thanks!