Reputation: 495
I have one html file which contain submission form.
I want to use this HTML form in django with model and view.
I dont want to use form class in html like
<form method="post" action="">
{% csrf_token %}
{{ form }}
<input type="submit" value="Register"/>
</form>
I want to use complete form code in HTML and use django model to store that data in database.
How can I do that?
Upvotes: 0
Views: 363
Reputation: 2586
Please update the question that you want to use jQuery.Django by defaults generate id for its form element.
As avinash already said you can always inspect the element and get the id and classses but some time we need custom class in that case you can use something like.
If you want to write your own custom fields.
class myForm(forms.ModelForm):
class Meta:
model = ModeName
widgets = {
'field_one': forms.TextInput(attrs={'id':'foo', 'name':'foo'})
'field_two': forms.TextInput(attrs={'id':'bar', 'name':'bar'})
}
Upvotes: 1