﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
35431	Failing to serialize NumericRange with CheckConstraint on IntegerRangeField	Arran	nobody	"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!"	Bug	closed	Migrations	5.0	Normal	invalid			Unreviewed	0	0	0	0	0	0
