Ah yeah.
Maybe:

collection_datetime =
forms.SplitDateTimeField(widget=forms.SplitDateTimeWidget())
collection_datetime.widget.widgets = (input1.. , input2..)
would do the trick?

I don't have a development env here so I am only guessing.
Anybody else has suggestions on this? Because it looks a little hacky...

TiNo


On 7/2/08, Tim Sawyer <[EMAIL PROTECTED]> wrote:
>
>
> Sorry, still not working.  I get:
>
> __init__() got an unexpected keyword argument 'widgets'
>
> Is that because widgets isn't a parameter to __init__ ? (I'm still getting
> to
> grips with python, it's so much more expressive than the Java I'm used to!)
>
> My code is:
>
> collection_datetime = forms.SplitDateTimeField(widget=
>
> forms.SplitDateTimeWidget(widgets=
>
>                                                                             (
>
> forms.TextInput({'class':'vDateField required'}),
>
> forms.TextInput({'class':'vTimeField required'})
>
> )
>
> )
>                                                   )
>
> ta,
>
> Tim.
>
> On Wednesday 02 Jul 2008, TiNo wrote:
> > Have a look at the source (widgets.py in newforms):
> > class SplitDateTimeWidget(MultiWidget):
> >     """
> >     A Widget that splits datetime input into two <input type="text">
> boxes.
> >     """
> >     def __init__(self, attrs=None):
> >         widgets = (TextInput(attrs=attrs), TextInput(attrs=attrs))
> >         super(SplitDateTimeWidget, self).__init__(widgets, attrs)
> >
> > So maybe:
> >
> > collection_datetime =
> > forms.SplitDateTimeField(
> >
> > widget=forms.SplitDateTimeWidget(
> >
> > widgets=(TextInput({'class':'vDateField required'}),
> >
> > TextInput({'class':'vTimeField'}))))
> >
> > will work?
> >
> >
> > On Wed, Jul 2, 2008 at 11:03 PM, Tim Sawyer <[EMAIL PROTECTED]>
> >
> > wrote:
> > > Thanks.
> > >
> > > I've got the class in the html but not the buttons for the date or time
> > > popup.
> > > I also have two date popups and I think I should have one that has the
> > > class
> > > vTimeField not vDateField.
> > >
> > > collection_datetime =
> > >
> > >
> forms.SplitDateTimeField(widget=forms.SplitDateTimeWidget({'class':'vDate
> > >Field required'}))
> > >
> > > in my form is generating:
> > >
> > > <tr><th><label for="id_collection_datetime_0">Collection
> > > datetime:</label></th><td><input id="id_collection_datetime_0"
> > > type="text" class="vDateField required" name="collection_datetime_0"
> > > /><input id="id_collection_datetime_1" type="text" class="vDateField
> > > required" name="collection_datetime_1" /></td></tr>
> > >
> > > in my html.
> > >
> > > Any ideas?
> > >
> > > Cheers,
> > >
> > > Tim.
> > >
> > > On Wednesday 02 Jul 2008, TiNo wrote:
> > > > Sorry, I was a little too quick. I used it like this:
> > > > date =
> > >
> > >
> forms.DateField(label=_("Date"),widget=forms.DateTimeInput(attrs={'class'
> > >:'
> > >
> > > >vDateField'}))
> > > >
> > > > I am not sure on how to do this on a SplitDateTimeField though.
> > > >
> > > > On Wed, Jul 2, 2008 at 10:52 PM, Tim Sawyer
> > > > <[EMAIL PROTECTED]>
> > > >
> > > > wrote:
> > > > > Sorry, I don't understand where I have to put the attrs bit.
> > > > >
> > > > > Can you give me an example?
> > > > >
> > > > > delivery_datetime =
> > > > > forms.SplitDateTimeField(attrs={'class':'vDateField'}) doesn't
> work,
> > > > > is that what you meant?
> > > > >
> > > > > Thanks,
> > > > >
> > > > > Tim.
> > > > >
> > > > > On Sunday 29 Jun 2008, TiNo wrote:
> > > > > > add:
> > > > > >
> > > > > > <script src="{% admin_media_prefix %}js/core.js"
> > >
> > > type="text/javascript"
> > >
> > > > > > ></script>
> > > > > >
> > > > > > <script src="{% admin_media_prefix %}js/admin/Calendar.js"
> > > > > > type="text/javascript" ></script>
> > > > > > <script src="{% admin_media_prefix
> %}js/admin/DateTimeShortcuts.js"
> > > > > > type="text/javascript" ></script>
> > > > > >
> > > > > > to your template, use SplitDateTimeField and pass the fields:
> > > > > >
> > > > > > attrs={'class':'vDateField'}
> > > > > >
> > > > > > That way you have the same date and time input as the admin
> > >
> > > interface.
> > >
> > > > > > TiNo
> > > > > >
> > > > > > On Sun, Jun 29, 2008 at 10:46 PM, Tim Sawyer
> > > > > > <[EMAIL PROTECTED]
> > > > > >
> > > > > > wrote:
> > > > > > > Hi Folks,
> > > > > > >
> > > > > > > What's the simplest approach for me to have a form that makes
> it
> > >
> > > easy
> > >
> > > > > for
> > > > >
> > > > > > > the
> > > > > > > user to enter a Date/Time combination?
> > > > > > >
> > > > > > > I have my form class specified (the field in question is a
> > > > > > > forms.DateTimeField()), but I need to make it easy for users of
> > > > > > > the
> > > > >
> > > > > site
> > > > >
> > > > > > > to enter a date/time pair for the field.
> > > > > > >
> > > > > > > Is there a simple way to do this?  I'm using jQuery for
> > > > > > > javascript
> > >
> > > on
> > >
> > > > > the
> > > > >
> > > > > > > site
> > > > > > > if that's relevant.
> > > > > > >
> > > > > > > Thanks,
> > > > > > >
> > > > > > > Tim.
> > > > >
> > > > > -------------------------------------------------------
> >
> >
>
>
> >
>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to