I have a Student detail page where I have all the student data shown in a log nested format.
Now in the form I know I can add a help text. But now my manager wants that when we show the detail page, there should be help on hovering over each field.
Now I am confused where should I enter 50-100 words help text for each table in 5-6 tables
This is how I used help_text in the forms:
student_number = forms.CharField( required=False, max_length=64, label='Student Number', help_text='Unique identifier for the student ')
help_text attribute is used to display the “help” text along with the field in form in admin interface or ModelForm. It's useful for documentation even if your field isn't used on a form. For example, you can define the pattern of date to be taken as input in the help_text of DateField.
For example, adding an argument null = True to TextField will enable it to store empty values for that table in relational database. Here are the field options and attributes that an TextField can use. If True, Django will store empty values as NULL in the database. Default is False.
help_text = 'My help text' class Meta: model = MyModel exclude = () @admin. register(MyModel) class MyModelAdmin(admin. ModelAdmin): form = MyForm # ... Show activity on this post.
Yes you can! Just like your form, you can add help_text
to your model fields.
When using model forms you can add labels and help_texts to fields generated by the model. see docs
class PupilForm(forms.ModelForm): class Meta: model = Pupil fields = ['student_number',] labels = {'student_number': "Student Number",} help_texts = {'student_number': "Unique identifier for the student",}
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