讀如果我從我剛保存的文件,以我一個DB「讀出」得到:Django的從數據庫
您的姓名是:(u'Mike」,)
你的生日是:(日期時間.datetime(2009,12,5,0,0))
而不是
你的名字是邁克
你的生日是在12/05/2009
我該如何做到這一點?
感謝
@丹尼爾:
同樣是你回答我的例子之前:
這是它是如何保存:
def main(request):
if request.method == 'POST':
form = UserForm(request.POST)
if form.is_valid():
name = form.cleaned_data['name'],
birth_day = form.cleaned_data['birth_day'],
address = form.cleaned_data['address'],
# contact1= form.cleaned_data['id']
phone_type = form.cleaned_data['phone_type']
phonenumber = form.cleaned_data['phonenumber']
contact = Contact(
name = form.cleaned_data['name'],
birth_day = form.cleaned_data['birth_day'],
address = form.cleaned_data['address'],
)
contact.save()
number = PhoneNumber(
# contact1 = form.cleaned_data ['id']
contact = contact,
phone_type = form.cleaned_data['phone_type'],
phonenumber = form.cleaned_data['phonenumber'],
)
number.save()
,這如何顯示:
output = '''
<html>
<head>
<title> Your telephone number </title>
</head>
<body>
<h1> Your telephone number</h1>
<p>Your Name is: %s </p>
<p>Your Telephone number is : %s </p>
<p>Your Address is: %s </p>
<p>This is your %s number </p>
<p>Your Birthday is on: %s </p>
</body>
</html>''' %(name, phonenumber, address, phone_type, birth_day)
return HttpResponse(output)
顯示一些代碼!你如何保存數據?你如何加載它?你怎麼輸出它? – 2010-09-06 08:55:02
你能告訴我們UserForm的聲明嗎? – dmitko 2010-09-06 09:25:26