Friday, March 27, 2015

Python: Django

To take a leap forward through server side developmental years, I am now working through a Django tutorial. Certain advantages, such as scalability I don't yet benefit from. Though the safe simplicity of managing changes to models is an asset I can admire. Mainly due to several years of working with a software that at times required exact modifications to SQL tables to support front end changes. The models in Django enable the user to access and alter data stored in the tables. Lucky for me I've started using Django version 1.7 which includes the migrate commands, benefits explained below.

Challenge: How to modify an existing model

Solution (Django < 1.7): This developer making a change manually would have to update the table with the exact Django expected syntax, and make perfect reflected changes to Or the developer could back up the data, wipe out the table, recreate it using syncdb, and reload the data.

Solution (Django >= 1.7): This developer updates the file, run makemigrations, run migrate.

Not only does Django handle update the sql table perfectly, but a file is produced in the migrations folder that shows you the exact changes made in case you would like to change any. It is possible as well to use the command sqlmigrate to view the changes Django plans to make on your table.

Of course before hand the developer could have installed South, but the point here is the wonderful benefit of the now built in functionality. The migrate commands empower the developer to make changes to the project with little work and a lot of security. 

No comments:

Post a Comment