Hi,

I think you want something like this.

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

Collin

On Monday, December 19, 2016 at 1:13:17 PM UTC-6, Farhan Khan wrote:
>
> Unfortunately that does not display.
> In the template I had it as {{ fourteen }} and saw it was rendering 
> everything but my custom widget.
>
> --
> Farhan Khan
> PGP Fingerprint: 4A78 F071 5CB6 E771 B8D6 3910 F371 FE22 3B20 B21B
>
> On Mon, Dec 19, 2016 at 2:02 PM, Matthew Pava <[email protected] 
> <javascript:>> wrote:
>
>> I’m not that familiar with MultiWidget, but it would seem that your print 
>> statement should be:
>>
>> print(fourteen.mywidget)
>>
>>  
>>
>> *From:* [email protected] <javascript:> [mailto:
>> [email protected] <javascript:>] *On Behalf Of *Farhan Khan
>> *Sent:* Monday, December 19, 2016 11:40 AM
>> *To:* Django users
>> *Subject:* 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 
>> <https://docs.djangoproject.com/en/1.10/ref/forms/widgets/#multiwidget> 
>> 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 [email protected] <javascript:>.
>> To post to this group, send email to [email protected] 
>> <javascript:>.
>> 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
>>  
>> <https://groups.google.com/d/msgid/django-users/86bebdb4-1d45-4612-84d1-456f86942709%40googlegroups.com?utm_medium=email&utm_source=footer>
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
>> -- 
>> You received this message because you are subscribed to a topic in the 
>> Google Groups "Django users" group.
>> To unsubscribe from this topic, visit 
>> https://groups.google.com/d/topic/django-users/hUmvw-mdaiY/unsubscribe.
>> To unsubscribe from this group and all its topics, send an email to 
>> [email protected] <javascript:>.
>> To post to this group, send email to [email protected] 
>> <javascript:>.
>> 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/ebd9f58fca3a4009abcfd05e16fca9dc%40ISS1.ISS.LOCAL
>>  
>> <https://groups.google.com/d/msgid/django-users/ebd9f58fca3a4009abcfd05e16fca9dc%40ISS1.ISS.LOCAL?utm_medium=email&utm_source=footer>
>> .
>>
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>

-- 
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 [email protected].
To post to this group, send email to [email protected].
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/9eaec86d-7df1-4fae-bf9b-6d8af62e6154%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to