This is a newbie theory question – I’m just starting to use Python and looking into Django and orm. Question: If I develop my objects and through additional development modify the base object structures, inheritance, etc. – would Django’s ORM solution modify the database automatically OR do I need to perform a conversion (if the app is live)?
So, I start with a basic Phone app
Object person: name, address, city, state, zip, phone
and I change to
Object person: title, name, address, city, state, zip, phone object
Object phone: type, phone #
Do I manually convert via the db and change the code OR does the ORM middleware make the change? and if so – how?
The Django book covers this issue in Chapter 5, near the end of the chapter (or bottom of the page, in the web edition). Basically, the rules are:
ALTER TABLE) and then add the field to the model. (You can usemanage.py sqlallto see what SQL statement to execute.)ALTER TABLEcommand), and any join tables that were created.So to answer your question, in Django’s case, no, the ORM will not handle modifications for you — but they’re not that hard to do. See that chapter of the book (linked above) for more info.