1

I want to override the required error message. For blank and empty I can do it in extra_kwargs, but for required it doesn't work:

class Meta:
    extra_kwargs = {
        'enticements_info': {'error_messages': {'required': 'Test.'}},
    }

What can I do?

1 Answer 1

4

You can override the required error_message in this way.

class YourSerializer(ModelSerializer):
    my_default_errors = {
        "required": "This field is required",
        "blank": "This field should not blank",
    }

    enticements_info = serializers.CharField(
        required=True, error_messages=my_default_errors, min_length=10
    )

    class Meta:
        model = Your_Model
        fields = "enticements_info"
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.