Monday, December 19, 2016

MultiWidget not rendering

Hi all!
I am trying to get a MultiWidget with two TextFields ,however I am not able to get anything to render. Here is my code.

from django import forms
from django.forms import widgets

class DateSelectorWidget(widgets.MultiWidget):
   
def __init__(self, attrs=None):
        _widgets
= (forms.TextInput(),
                    forms
.TextInput())
       
super(DateSelectorWidget, self).__init__(_widgets, attrs)

   
def format_output(self, rendered_widgets):
       
return ''.join(rendered_widgets)

class Fourteen(forms.Form):
    mywidget
= DateSelectorWidget()


In the shell I will do:

>>> fourteen = Fourteen()
>>> print(fourteen)

>>>

Nothing will render. I suspect that I need to manually render the HTML, but the documentation is fairly light on this topic.

Any assistance would be greatly appreciated!

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/86bebdb4-1d45-4612-84d1-456f86942709%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment