Reputation: 4706
I am attempting to obtain a value which is present in a form that is passed to my template. This is what my view does
return render(request, 'manageStudent.html',
{'form': StudentDetails(
initial={
'school_name': rslt[0][1],
'student_user_name': rslt[0][3],
}
),}
I am attempting to read the username using the following way in my template
This is the data {{ form.fields.student_user_name.initial}}
However i simply get None in response. I tried the suggestions here but none seem to work in my case. Any suggestions ?
Upvotes: 0
Views: 46
Reputation: 141
Try
{{ form.initial.student_user_name }}
That works for me in django 1.7 when I initialize my form using
StudentDetails(instance=student_details_obj)
Upvotes: 2