jax
jax

Reputation: 4197

Is there any method to set default value form.charField()?

I have created a form to take input from an HTML page like given bellow:

form.py 

  class In_Form(forms.Form):
        Input_peptide  = forms.CharField(label='Start Year ', max_length=100)
        sites_to_be_muted = forms.CharField(label='End Year', max_length=100)
        Amino_acide = forms.CharField(label='End Year ', max_length=100,)

Update:

Is there any method through which I can set a default value for html form. I have tried "initial" but its not working in my case. This form.py is not related to model its just a form getting user input and processing that data through a script and returning result to a view and rendering output as "result.html" page: please help

Upvotes: 0

Views: 1329

Answers (1)

aprasanth
aprasanth

Reputation: 1099

Use the initial argument when you create a Form instance.

form = In_Form(initial={'Input_peptide': '2017'})

Reference

Upvotes: 1

Related Questions