i have a form which is like
from django import forms
from captcha.fields import CaptchaField
from django.shortcuts import render_to_response
from OEConnector import *
class Personal_info_updateForm(forms.Form):
title_choices = ( ('herr', 'Herr'), ('frau', 'Frau'))
#Dates tuple list
dates=[]
for x in range(1,32):
dates.append(tuple([x.__str__(),x.__str__()]))
dates = tuple(dates)
#Months tuple list
months = (
('jan','Januar'),
('feb','Februar'),
('mar','Marz'),
('apr','April'),
('may','Mai'),
('jun','Juni'),
('jul','Juli'),
('aug','August'),
('sep'开发者_运维知识库,'September'),
('oct','Oktober'),
('nov','November'),
('dec','Dezember'),
)
#Years tuple list
years=[('','')]
for y in range(1930,2050):
years.append(tuple([y.__str__(),y.__str__()]))
years = tuple(years)
#Get list of countries from OpenERP and create countries tuple list
title = forms.ChoiceField(label="Anrede", choices=title_choices, widget=forms.RadioSelect)
first_name = forms.CharField(label="Vorname", required=False)
last_name = forms.CharField(label="Nachname", required=False)
date_of_birth = forms.ChoiceField(choices=dates, widget=forms.Select, required=False)
month_of_birth = forms.ChoiceField(choices=months, widget=forms.Select, required=False)
year_of_birth = forms.ChoiceField(choices=years, widget=forms.Select, required=False)
email = forms.EmailField(label='Email',required=False)
phone = forms.CharField(label="Phone", required=False)
mobile = forms.CharField(label="Mobile", required=False)
i am calling this form in my template.It shows me like Date of birth:
Month of birth: Year of birth:Now i want that these three fields come in a single line like Date of birth: Month of birth: Year of birth:
My template is like
<form action="" method="POST">
<table style="color:black;text-align:left; margin-left: 20px;">
{{ form.as_table }}
</table>
<input type="submit" value="UPDATE">
</form>
I want like Date of birth: Month of birth: Year of birth:
Thanks in advance
rather then splitting the field you could use a DateField with the SelectDateField widget e.g.
forms.DateField(widget=SelectDateWidget(years=[y for y in range(1930,2050)]))
this would display as one row in the form - [month][day][year]
精彩评论