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

paypal - How to know the URL referrer in PHP? -

oauth - Facebook OAuth2 Logout does not remove fb_ cookie -

wpf - Line breaks and indenting for the XAML of a saved FlowDocument? -