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
- [Django]-How to use django migrate without confirmation
- [Django]-502 error after adding application to a Django project running on nginx and gunicorn
- [Django]-Django Rest Framework IsAuthenticated permission Error Anonymous user
- [Django]-Encrypt and Decrypt information in a cookie
- [Django]-Django SESSION_COOKIE_DOMAIN
2👍
you can add help_text attribute in models.py
name = models.CharField(max_length=60, help_text="Your help text here....")
Source:stackexchange.com