diff options
author | Johannes Raggam <raggam-nl@adm.at> | 2011-12-02 09:50:16 (GMT) |
---|---|---|
committer | Johannes Raggam <raggam-nl@adm.at> | 2011-12-02 09:50:16 (GMT) |
commit | 4ea7cae98e7161c22e3eb81c8131df3d72b35f1f (patch) | |
tree | 075ad8467e3ce542bfe97b25aabdac2b5d63ee7c /nop | |
parent | 0af80555fb9c00d59d45aa4e69c3cb3e80e5c2cd (diff) |
form-level dynamic field initialization
Diffstat (limited to 'nop')
-rw-r--r-- | nop/views.py | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/nop/views.py b/nop/views.py index 4759cdc..0ec1c61 100644 --- a/nop/views.py +++ b/nop/views.py @@ -25,14 +25,16 @@ MUSIKPROG_IDS = (1,5,17,34,60,81,89) class NopForm(forms.Form): date = forms.DateField( required=True, - initial=datetime.date(datetime.now()), + #initial=datetime.date(datetime.now()), ## static initial specifies + ## any time but not the + ## current one widget=forms.DateInput( format='%Y-%m-%d', attrs={'id':'nop_date', 'class':'date'}) ) time = forms.TimeField( required=True, - initial=datetime.time(datetime.now()), + #initial=datetime.time(datetime.now()), widget=forms.TimeInput( format='%H:%M', attrs={'id':'nop_time', 'class':'date'}) @@ -129,7 +131,8 @@ def nop_form(request): date = form.cleaned_data['date'] time = form.cleaned_data['time'] else: - form = NopForm() + form = NopForm(initial={'date':datetime.date(datetime.now()), + 'time':datetime.time(datetime.now())}) if not date: date = datetime.date(datetime.now()) if not time: time = datetime.time(datetime.now()) result = _bydate(date.year, date.month, date.day, time.hour, time.minute) |