I am creating a form that creates the form dynamically using my forms.py file in my django app.
Here is my code..
forms.py
class TestCriteriaForm(forms.Form):
testname = forms.CharField()
serviceoffering = forms.ModelChoiceField(queryset=ServiceOffering.objects.all())
templatename = forms.CharField(help_text="Enter the template name" )
zone = forms.CharField()
template code
<form action="/testplatform/" method="post">{% csrf_token %}
{{ form.as_p }}
<input type="submit" value="Submit" />
</form>
My problem is that the field names aren’t formatted to my liking. Rather than testname, I would like to see ‘Test name’, or ‘Service Offering’
How can I do this without defining more html code than I have to in the template?
Many thanks – Oli
Use the
labeloption.Look at the docs next time.