[Django]-DRF APIView – How can I add help text to auto generated form?

11👍

Specify help_text as additional keyword argument (see documentation) instead declaring a serializer field specifying all options that are already in the model field (unique, null, max_length etc.)

class MySerializer(serializers.ModelSerializer):
    class Meta:
        model = MyModel
        fields = ('id','name', ...)
        extra_kwargs = {
            'name': {
                'help_text': 'You help text here...'
            }
        }

4👍

You could add the help text using help_text argument of serializer field

class MySerializer(serializers.ModelSerializer):
    name = serializers.CharField(help_text="foo bar")
    class Meta:
        Model = MyModel
        fields = ('id','name', ...)
👤JPG

2👍

you can add help_text attribute in models.py

name = models.CharField(max_length=60, help_text="Your help text here....")

More Info…

Leave a comment