You can pass a 2nd variable on the except
statement. It will hold the text error. See below
if request.method == 'POST':
form = CustomerForm(request.POST)
if form.is_valid():
try:
customer = form.save(commit=False)
customer.save()
except DatabaseError, text_error:
message = u'Database Error: {0}'.format(text_error)