2016-11-05 11:35:58 +01:00
|
|
|
from django.contrib.gis.db import models
|
2011-09-10 03:04:30 +00:00
|
|
|
|
2015-04-04 18:09:46 +02:00
|
|
|
from ..admin import admin
|
|
|
|
|
2013-11-02 13:12:09 -07:00
|
|
|
|
2011-09-10 03:04:30 +00:00
|
|
|
class City(models.Model):
|
|
|
|
name = models.CharField(max_length=30)
|
|
|
|
point = models.PointField()
|
2014-01-01 11:01:46 +01:00
|
|
|
|
2015-03-21 16:59:30 +01:00
|
|
|
class Meta:
|
|
|
|
app_label = "geoadmin"
|
|
|
|
|
2013-10-17 09:17:41 +01:00
|
|
|
def __str__(self):
|
|
|
|
return self.name
|
2011-09-10 03:04:30 +00:00
|
|
|
|
2015-12-04 15:37:39 +05:00
|
|
|
|
2021-12-17 20:40:22 +03:00
|
|
|
class CityAdminCustomWidgetKwargs(admin.GISModelAdmin):
|
|
|
|
gis_widget_kwargs = {
|
|
|
|
"attrs": {
|
|
|
|
"default_lat": 55,
|
|
|
|
"default_lon": 37,
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-12-09 19:12:56 +02:00
|
|
|
site = admin.AdminSite(name="gis_admin_modeladmin")
|
|
|
|
site.register(City, admin.ModelAdmin)
|
|
|
|
|
|
|
|
site_gis = admin.AdminSite(name="gis_admin_gismodeladmin")
|
|
|
|
site_gis.register(City, admin.GISModelAdmin)
|
2021-12-17 20:40:22 +03:00
|
|
|
|
|
|
|
site_gis_custom = admin.AdminSite(name="gis_admin_gismodeladmin")
|
|
|
|
site_gis_custom.register(City, CityAdminCustomWidgetKwargs)
|