python - Set custom 'name' attribute for RadioSelect in Django -


I am trying to set a custom 'name' attribute in the digenfo form.

I have been trying this kind of approach:

  class BaseQuestionForm (forms.Form): question_id = forms.CharField (widget = forms.HiddenInput) answer = Forms.ChoiceField (option = [...], widget = forms. Radios select)  

and then on answer : ' - setting :

  form.fields ['answer']. Widget.name = 'new_name'  

But this does not work, and the name is always set as the field name on 'Answer'. Is there any way to do this?

First try:

  I believe the widget The name is not (well, I'm pretty sure; -))     

What do you want to do, you have to:

  form.fields ['new_name'] = form .fields ['answer'] del form.fields ['answer']  

If you simply use {{form}} in the template Anyway, the new_name will go to the bottom of the field (this dictionary is ordered). DJ ango creates form field names in the template named after names.


Comments

Popular posts from this blog

c# - sqlDecimal to decimal clr stored procedure Unable to cast object of type 'System.Data.SqlTypes.SqlDecimal' to type 'System.IConvertible' -

Calling GetGUIThreadInfo from Outlook VBA -

Obfuscating Python code? -