class LabelSerializer(serializers.ModelSerializer):
def validate(self, attrs):
if "prefix_key" not in attrs and "suffix_key" not in attrs:
return super().validate(attrs)
prefix_key = attrs["prefix_key"]
After Change
try:
context = self.context["request"].parser_context
project_id = context["kwargs"]["project_id"]
label_id = context["kwargs"].get("label_id")
except (AttributeError, KeyError):
pass // unit tests don"t always have the correct context set up
else:
conflicting_labels = Label.objects.filter(