I am trying to run the following code here to save information to the database. I have seen other messages - but - it appears that the solutions are for older versions of Python/DJango
(as they do not seem to be working on the versions I am using now: Python 3.6.3
and DJango 1.11.7
if form.is_valid():
try:
item = form.save(commit=False)
item.tenantid = tenantid
item.save()
message = 'saving data was successful'
except DatabaseError as e:
message = 'Database Error: ' + str(e.message)
When doing so, I get an error message the error message listed below. How can I fix this so I can get the message found at the DB level printed out?
'DatabaseError' object has no attribute 'message'
Request Method:
POST
Request URL:
http://127.0.0.1:8000/storeowner/edit/
Django Version:
1.11.7
Exception Type:
AttributeError
Exception Value:
'DatabaseError' object has no attribute 'message'
Exception Location:
C:\WORK\AppPython\ContractorsClubSubModuleDEVELOP\libmstr\storeowner\views.py in edit_basic_info, line 40
Python Executable:
C:\WORK\Software\Python64bitv3.6\python.exe
Python Version:
3.6.3
Python Path:
['C:\\WORK\\AppPython\\ContractorsClubSubModuleDEVELOP',
'C:\\WORK\\Software\\OracleInstantClient64Bit\\instantclient_12_2',
'C:\\WORK\\Software\\Python64bitv3.6\\python36.zip',
'C:\\WORK\\Software\\Python64bitv3.6\\DLLs',
'C:\\WORK\\Software\\Python64bitv3.6\\lib',
'C:\\WORK\\Software\\Python64bitv3.6',
'C:\\Users\\dgmufasa\\AppData\\Roaming\\Python\\Python36\\site-packages',
'C:\\WORK\\AppPython\\ContractorsClubSubModuleDEVELOP\\libintgr',
'C:\\WORK\\AppPython\\ContractorsClubSubModuleDEVELOP\\libmstr',
'C:\\WORK\\AppPython\\ContractorsClubSubModuleDEVELOP\\libtrans',
'C:\\WORK\\AppPython\\ContractorsClubBackofficeCode\\libintgr',
'C:\\WORK\\AppPython\\ContractorsClubBackofficeCode\\libmstr',
'C:\\WORK\\TRASH\\tempforcustomer\\tempforcustomer\\libtempmstr',
'C:\\WORK\\AppPython\\ContractorsClubBackofficeCode\\libtrans',
'C:\\WORK\\Software\\Python64bitv3.6\\lib\\site-packages',
'C:\\WORK\\Software\\Python64bitv3.6\\lib\\site-packages\\django-1.11.7-py3.6.egg',
'C:\\WORK\\Software\\Python64bitv3.6\\lib\\site-packages\\pytz-2017.3-py3.6.egg']
Server time:
Sat, 9 Dec 2017 08:42:49 +0000
Just change
str(e.message)
to
str(e)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With