﻿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
34805	'Q' object has no attribute 'replace_expressions'	Petr Přikryl	nobody	"Hi, I have problem with calling full_clean on Model object with following constraint containing Q:

{{{
models.UniqueConstraint(
    models.Q(color__isnull=True),
    ""product"",
    condition=models.Q(color__isnull=True),
    name=""unique_product_color_null"",
),
}}}

Constraint is allowing only one NULL and works well. More at [https://www.enterprisedb.com/postgres-tutorials/postgresql-unique-constraint-null-allowing-only-one-null]

Traceback
{{{
/usr/local/lib/python3.11/site-packages/django/db/models/base.py:1497: in full_clean
    self.validate_constraints(exclude=exclude)
/usr/local/lib/python3.11/site-packages/django/db/models/base.py:1445: in validate_constraints
    constraint.validate(model_class, self, exclude=exclude, using=using)

/usr/local/lib/python3.11/site-packages/django/db/models/constraints.py:346: AttributeError
>               expressions.append(Exact(expr, expr.replace_expressions(replacements)))
E               AttributeError: 'Q' object has no attribute 'replace_expressions'
}}}

https://github.com/django/django/blob/4.2.4/django/db/models/constraints.py#L346"	Uncategorized	closed	Database layer (models, ORM)	4.2	Normal	invalid			Unreviewed	0	0	0	0	0	0
