diff --git a/django/db/backends/base/schema.py b/django/db/backends/base/schema.py index 55835fe535..bc8e54989e 100644 --- a/django/db/backends/base/schema.py +++ b/django/db/backends/base/schema.py @@ -292,7 +292,7 @@ class BaseDatabaseSchemaEditor: for fields in model._meta.unique_together: columns = [model._meta.get_field(field).column for field in fields] self.deferred_sql.append(self._create_unique_sql(model, columns)) - constraints = [check.constraint_sql(model, self) for check in model._meta.constraints] + constraints = [constraint.constraint_sql(model, self) for constraint in model._meta.constraints] # Make the table sql = self.sql_create_table % { "table": self.quote_name(model._meta.db_table), diff --git a/tests/constraints/tests.py b/tests/constraints/tests.py index 995c5f461c..c6a36ade07 100644 --- a/tests/constraints/tests.py +++ b/tests/constraints/tests.py @@ -80,8 +80,8 @@ class UniqueConstraintTests(TestCase): def test_deconstruction(self): fields = ['foo', 'bar'] name = 'unique_fields' - check = models.UniqueConstraint(fields=fields, name=name) - path, args, kwargs = check.deconstruct() + constraint = models.UniqueConstraint(fields=fields, name=name) + path, args, kwargs = constraint.deconstruct() self.assertEqual(path, 'django.db.models.UniqueConstraint') self.assertEqual(args, ()) self.assertEqual(kwargs, {'fields': tuple(fields), 'name': name})