Skip to content

Commit ca72094

Browse files
auvipyCopilot
andauthored
Apply suggestions from code review
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
1 parent 247531b commit ca72094

2 files changed

Lines changed: 7 additions & 4 deletions

File tree

rest_framework/serializers.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1528,6 +1528,8 @@ def get_uniqueness_extra_kwargs(self, field_names, declared_fields, extra_kwargs
15281528
default = ''
15291529
else:
15301530
default = empty
1531+
else:
1532+
default = empty
15311533

15321534
if unique_constraint_name in model_fields:
15331535
# The corresponding field is present in the serializer

tests/test_validators.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -640,10 +640,11 @@ class Meta:
640640
constraints = [
641641
# Unique constraint on one required field (age) and one blank field (tag)
642642
models.UniqueConstraint(
643-
name='unique_constraint',
644-
fields=('age', 'tag'),
645-
condition=~models.Q(models.Q(title='') & models.Q(tag='True')))
646-
]
643+
name='unique_constraint',
644+
fields=('age', 'tag'),
645+
condition=~models.Q(tag=''),
646+
)
647+
]
647648

648649

649650
class UniqueConstraintReadOnlyFieldModel(models.Model):

0 commit comments

Comments
 (0)