Skip to content

Check constraints are not validated in the Django admin

I did some quick checks to find out which models are affected:

from django.contrib.admin import site
[(modeladmin, modeladmin.model._meta.constraints) for modeladmin in site._registry.values() if modeladmin.model._meta.constraints]

Four models got returned: Image, Element, MetaData and WorkerVersion. The constraints on Element are not relevant here because they only apply to fields that cannot be changed through the admin (image, polygon, creator and worker version).

I did find HTTP 500 errors when testing for the other constraints:

  • ARKINDEX-BACKEND-VM: Changing a metadata's type to numeric when it is not actually a float
  • ARKINDEX-BACKEND-VJ: Setting the docker image to None on an available WorkerVersion, or setting a checked image's dimensions to zero
Edited by Erwan Rouchet