#35431: Failing to serialize NumericRange with CheckConstraint on IntegerRangeField --------------------------------------+------------------------ Reporter: Arran | Owner: nobody Type: Bug | Status: new Component: Migrations | Version: 5.0 Severity: Normal | Keywords: Triage Stage: Unreviewed | Has patch: 0 Needs documentation: 0 | Needs tests: 0 Patch needs improvement: 0 | Easy pickings: 0 UI/UX: 0 | --------------------------------------+------------------------ I am trying to create a PostgreSQL check constraint on an `IntegerRangeField`, but when I run `makemigrations` I get the following error:
{{{ ValueError: Cannot serialize: Range(1, 10000, '[)') There are some values Django cannot serialize into migration files. }}} Here's a simple example of my model which raises the error: {{{ from django.contrib.postgres.fields import IntegerRangeField from django.db.backends.postgresql.psycopg_any import NumericRange from django.db import models from django.db.models.constraints import CheckConstraint from django.db.models.expressions import Q class MyModel(models.Model): price_range = IntegerRangeField() class Meta: constraints = [ CheckConstraint( check=Q(price_range__contained_by=NumericRange(1, 10000)), name="price_range_gt_1_and_lte_10000", ) ] }}} Judging by the following ticket this should work, so any help would be welcome: [https://code.djangoproject.com/ticket/30258] Thanks! -- Ticket URL: <https://code.djangoproject.com/ticket/35431> 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 view this discussion on the web visit https://groups.google.com/d/msgid/django-updates/0107018f43a6a863-f7ead347-c8ac-4218-991d-3c2689b52eb4-000000%40eu-central-1.amazonses.com.