[Answered ]-Django read from db

1👍

But that’s not read from the database, it’s taken straight from the form submission. Instead, use the objects you’ve just saved. You’ll need to do a bit of extra formatting on the birthday though:

% (contact.name, number.phonenumber, contact.address, 
   number.get_phone_type_display(), 
   contact.birth_day.strftime('%d/%m/%Y'))

1👍

name = form.cleaned_data['name'],
birth_day = form.cleaned_data['birth_day'],
address = form.cleaned_data['address'],

I think you have tuple because of commas (,) at the end of the lines! Remove them and try again 🙂

👤dmitko

0👍

How are you ‘reading out’ from the database? If you are connecting to the database using a library (say MySQLdb), executing a query and printing the output (say, using fetch_row()), then the result you are getting is natural.

The result will be a tuple and you’ll have to extract the field you need. This can be done using an appropriate index. Say:

result = fetch_row()
print "Your Name is: %s" % result[0]

Update

(After seeing the updated question): @Daniel’s answer should help you out.

Leave a comment