I am working with Django Rest Framework and using APIView and serializer form to add new data. I want to add some help text to the form as tooltip. Since the form is auto generated, I need some help on how can I add this to the form. I am using ModelSerializer.
This is how my serializer looks like
class MySerializer(serializers.ModelSerializer):
class Meta:
Model = MyModel
fields = ('id','name', ...)
My form fields should have help texts. How can I add them? Thanks!
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...'
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With