This can be a newbie theory question - I am just beginning to make use of Python and considering Django and orm. Question: Basically develop my objects and thru additional development customize the base object structures, inheritance, etc. - would Django's ORM solution customize the database instantly OR should i execute a conversion (when the application is live)?
So, I begin with a fundamental Phone application Object person: title, address, city, condition, zip, phone and that i switch to Object person: title, title, address, city, condition, zip, phone object Object phone: type, phone #
Will I by hand convert through the db and alter the code OR does the ORM middleware result in the change? and when so - how?
By Django 1.02 (and by the most recent run-as much as 1.one in subversion), there's no automatic "schema migration". Your options will be to drop the schema and also have Django recreate it (via manage.py syncdb), or affect the schema manually yourself.
You will find some tools coming for Django schema migration. (I am watching South.)
The Django book covers this problem in Chapter 5, close to the finish from the chapter (or bottom from the page, within the web edition). Essentially, the guidelines are:
- When adding a area, first combine it with the database by hand (using, e.g.,
ALTER TABLE) after which add the area towards the model. (You should use
manage.py sqlallto determine what SQL statement to complete.)
- When getting rid of a area, take it out of your model after which execute the right SQL statement to get rid of the column (e.g., an
ALTER TABLEcommand), and then any join tables which were produced.
- Renaming a area is essentially a mix of adding/getting rid of fields, in addition to copying data.
To answer your question, in Django's situation, no, the ORM will not handle modifications for you personally -- but they are not too difficult to do. Observe that chapter from the book (linked above) for more information.
We incorporate a 'version' number within the application title.
Our sites seem like this
project settings.py appA_1 __init__.py models.py tests.py appB_1 __init__.py models.py tests.py appB_2 __init__.py models.py tests.py
This shows two versions of appB. appB_1 was the initial version. Whenever we transformed the model, we began by copying the application to produce appB_2, after which modified that certain.
manage.py syncdb can create the modern appB_2.
We must unload and reload the tables by copying from appB_1 to appB_2. Once.
Only then do we can remove appB_1 in the configurations.py. Later we are able to remove the tables in the database.