We could directly create a simple form by inheriting forms.Form. However, I want forms to be dynamically created based on the key-value specified by the admin. Consider, user provides a map as :
[
{
"key": "name",
"value": "CharField"
},
{
"key": "url",
"value": "URLField"
}
]
Based on the map given above how can I create a form which is equivalent to the class based form creation below:
from django import forms
class CommentForm(forms.Form):
name = forms.CharField(label='name')
url = forms.URLField(label='url')
My current approach might be to iterate across each key-value pair and make a HTML form manually. Is it possible to create dynamic forms in django without having to write a class definition?
label,choices, etc.) from?