#27674: Deprecate GeoModelAdmin and OSMGeoAdmin --------------------------------------+------------------------------------ Reporter: Claude Paroz | Owner: nobody Type: Cleanup/optimization | Status: new Component: GIS | Version: master Severity: Normal | Resolution: Keywords: | Triage Stage: Accepted Has patch: 0 | Needs documentation: 0 Needs tests: 0 | Patch needs improvement: 0 Easy pickings: 0 | UI/UX: 0 --------------------------------------+------------------------------------
Comment (by Claude Paroz): Sure. The typical example is to be sure all geometry widgets use a specific map widget, or specific map widget attributes. With `formfield_overrides`, you'd have to specify all field types: {{{ class MyModelAdmin(admin.ModelAdmin): formfield_overrides = { models.PointField: {'widget': MyCustomMapWidget}, models.PolygonField: {'widget': MyCustomMapWidget}, models.LineField: {'widget': MyCustomMapWidget}, models.MultiPointField: {'widget': MyCustomMapWidget}, ... } }}} which is not nice if you have many geometry field types in your project. I think it's a case where `formfield_for_dbfield` is handy: {{{ class MyModelAdmin(admin.ModelAdmin): def formfield_for_dbfield(self, db_field, request, **kwargs): if isinstance(db_field, models.GeometryField) and db_field.dim < 3: kwargs['widget'] = OSMWidget(default_lon=151, default_lat=-33) return db_field.formfield(**kwargs) else: return super(GeoModelAdmin, self).formfield_for_dbfield(db_field, request, **kwargs) }}} An alternative would be to still provide a GIS admin utility (subclass or mixin) which sets the same map widget for all geometry fields, like the current `GeoModelAdmin.get_map_widget()`. Basically the current code without all the boiler plate code copying class attributes to widget attributes. -- Ticket URL: <https://code.djangoproject.com/ticket/27674#comment:2> Django <https://code.djangoproject.com/> The Web framework for perfectionists with deadlines. -- You received this message because you are subscribed to the Google Groups "Django updates" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-updates+unsubscr...@googlegroups.com. To post to this group, send email to django-updates@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/django-updates/065.dcdd8aec72163cdbec6185f2dffedda1%40djangoproject.com. For more options, visit https://groups.google.com/d/optout.