How to add verbose_name
to forms in Django?
In forms.py:
class SendOrderForm(forms.Form): send_option = forms.ModelChoiceField(queryset=Send.objects.all(), verbose_name="Send Options")
This is not correct
First, create a model that contains fields name and other metadata. It can be used to create a table in database and dynamic HTML form. This file contains a class that inherits ModelForm and mention the model name for which HTML form is created. Write a view function to load the ModelForm from forms.py.
Set the exclude attribute of the ModelForm 's inner Meta class to a list of fields to be excluded from the form.
verbose_name is a human-readable name for the field. If the verbose name isn't given, Django will automatically create it using the field's attribute name, converting underscores to spaces. This attribute in general changes the field name in admin interface.
I think, label argument is what you need:
class SendOrderForm(forms.Form): send_option = forms.ModelChoiceField(queryset=Send.objects.all(), label="Send Options")
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