geodesign / django-raster

Django-raster allows you to create tiled map services (TMS) and raster map algebra end points for web maps. It is Python-based, and requires GeoDjango with a PostGIS backend.
BSD 3-Clause "New" or "Revised" License
96 stars 39 forks source link

ArrayField default issue with django > 1.9 #34

Closed dvdtho closed 5 years ago

dvdtho commented 5 years ago

https://github.com/geodesign/django-raster/blob/master/raster/models.py#L303

The defaults should be changed: from [] to list

https://docs.djangoproject.com/en/dev/ref/contrib/postgres/fields/#django.contrib.postgres.fields.ArrayField

If you give the field a default, ensure it’s a callable such as list (for an empty default) or a callable that returns a list (such as a function). Incorrectly using default=[] creates a mutable default that is shared between all instances of ArrayField.

Newer Django throws warnings: WARNINGS: raster.RasterLayerParseStatus.tile_levels: (postgres.E003) ArrayField default should be a callable instead of an instance so that it's not shared between all field instances. HINT: Use a callable instead, e.g., use list instead of [].

yellowcap commented 5 years ago

Good catch @dvdtho, thanks for the patch!