views:

41

answers:

1

Hi,

I have created a form class which is used to generate a formset. I can easily generate the formset with initial data in it. However, I need to write the value of one of my CharField elements in my form as the label for another field. In order to do get this dynamic name, I wrote {{ form.field }} as the value for label. But since field is a CharField, I get a input element in my form instead of a label.

I was wondering if there's any way to convert CharField to string so that I don't show my label as a input element without Javascript?

Thanks

A: 

{{ form.initial.field }} should work, as long as you don't need to update it in real-time.

Aram Dulyan
I just figured out how to solve my problem. I just created a zip element from form and my dynamic strings in my view with the appropriate string elements. Then in my template iterated through my form and that variable, and printed the label.
mohi666