In an earlier post, I talked about using
form.save(commit=False) in a class based view, and I showed a way to do it. Â However, I wasn’t looking far enough back to see the real question:
How can I add information not found on the form to the object before saving?
Thanks to a reply way down in this Google Groups post, I found what I needed, and I kicked my self for not seeing this earlier. Since I was using the default form logic to save the object, I could send the additional value to the form.
## Include the instance object before saving
def form_valid(self, form):
form.instance.institution = self.institution
I like this solution better than what I provided in the earlier post because it is a better object oriented approach.
Of course, I have used the older example all over my applications, so I’ve got some refactoring to do.
(Another post written for personal documentation)
Download these three packages from Oracle for the proper operating system (32 bit for me):
- Instant Client Basic-Lite
- Instant Client SDK
- Instand Client SQLPlus
Unzip and copy to /opt/oracle/11_2/instantclient
#Oracle client LD_LIBRARY_PATH setting
sudo ldconfig -v
Symbolic Link to Library
ln -s libclntsh.so.10.1 libclntsh.so
Install Python Library
The library is called cx-oracle. Use your favorite installation method. (Don’t forget about your virtual environment!)
Hope I remembered everything.
Found another post that outlines the procedure maybe a little better than I did, and includes notes on setting up
tnsnames.ora. See Install Oracle Instant Client 11.1 and cx_Oracle 4.4 on Ubuntu 8.04 on Technoblog.