0

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 ?

Community
  • 1
  • 1
James Franco
  • 4,516
  • 10
  • 38
  • 80

1 Answers1

2

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)
Ben Johnson
  • 141
  • 3
  • 18