I have found a workaroud to this, by using the AdminSplitDateTime
widget and then rendering field in the template, the right thing
happens:

in form code:

from django.contrib.admin import widgets as adminWidgets

class Dummy1Form(forms.ModelForm):
    name = forms.CharField(max_length = 100)
    created = forms.SplitDateTimeField(initial=datetime.datetime.now
(),
 
widget=adminWidgets.AdminSplitDateTime)

in template:
<label for="id_created" class="required">{% trans "Created:" %}</
label>
<p class="datetime">
        {{ form.created }}
</p>

I'm still curious on the original question though

Rob


On Dec 22, 12:45 pm, rtmie <[email protected]> wrote:
> I have a form with a  SplitDateTimeField and cannot figure out how to
> access the individual date and time elements in it from my template:
>
> class Dummy1(models.Model):
>     name =  models.CharField(max_length = 100)
>     created = models.DateTimeField(default = datetime.datetime.now())
>
> class Dummy1Form(forms.Form):
>     name = forms.CharField(max_length = 100)
>     created = forms.SplitDateTimeField(widget=forms.SplitDateTimeWidget
> ())
>     class Meta:
>         model = Dummy1
>
> In my template:
> <label for="id_created" class="required">{% trans "Created:" %}</
> label>
> <p class="datetime">
> {{ form.created }}
> </p>
>  will give me access to the 2 fields but if I want to do something
> like the old form , what syntax do I need to get at the individual
> elements:
>
> <label for="id_created" class="required">{% trans "Created:" %}</
> label>
> <p class="datetime">
>         {% trans "Date: "%}{{ form.created_date }}
>         <br />
>         {% trans "Time: "%}{{ form.created_time }}
> </p>
>
> I haven't found any doc on this
>
> Rgds
> Rob
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to [email protected]
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