Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Intro Talk on South and Django Con

Intro Talk on South and Django Con

Talk on South and Django Con for the Fort Collins Ptyhon Web meet up

Derek Stegelman

October 02, 2013
Tweet

More Decks by Derek Stegelman

Other Decks in Programming

Transcript

  1. DJANGO CON RECAP & SOUTH MIGRATIONS Fort Collins Python Web

    Development Oct 2013 Tuesday, October 1, 13
  2. DEREK STEGELMAN Software Engineer at Five Q (Web Agency) Previously

    at KSU Python/Django (3 yrs) OSS @dstegelman (Github) @derekstegelman Tuesday, October 1, 13
  3. Django Con 2012 in Chicago IL (My 2nd Con) Attendance

    down this year due to cost Plenty of new features and talks on third party libraries and services Parties/Social Activities with sponsors Sprints Lots of networking and job opportunities Everyone should go! Tuesday, October 1, 13
  4. Improved transaction management in 1.6 Addition of default DB Migrations

    in 1.7 (More on this later) Django and Salt Faster Tests Haystack 2.0 Tips/Tricks BEST OF THE BEST Tuesday, October 1, 13
  5. TRANSACTION IMPROVEMENTS Database level auto commit is now on by

    default in 1.6 Every query now runs as Atomic Better integrity and performance More details https://docs.djangoproject.com/en/dev/ topics/db/transactions/ Tuesday, October 1, 13
  6. DB MIGRATIONS Database migrations were overhauled and re-written for introduction

    into the core Experiment with kickstarter Upgrade path for 1.7 More on this in the South Talk Tuesday, October 1, 13
  7. DJANGO AND SALT Salt is the new-ish configuration management tool

    written in Python Can deploy as well as configure servers Recently seeing lots of activity as Django/Python community adopts over Chef Demo Tuesday, October 1, 13
  8. FASTER TESTS Tests can be slow Developer’s wont run tests

    if they are too slow Make sure unit tests really are unit tests Don’t touch the DB. Use mock or factory_boy Tuesday, October 1, 13
  9. HAYSTACK Haystack is just a light python wrapper around simple

    search engine methods Log users search queries and optimize Boosting Tuesday, October 1, 13
  10. More talk info and notes are available on my live

    noting page https://dstegelman-conf-notes.readthedocs.org/en/ latest/conferences/djangocon2013/index.html OTHER RESOURCES Tuesday, October 1, 13
  11. SCHEMA CHANGES (OR HOW I LEARNED TO STOP WORRYING AND

    LOVE SOUTH) Derek Stegelman Python Web Development Oct 1 2013 Tuesday, October 1, 13
  12. SYNCDB IS A MISNOMER SyncDB doesn’t sync anything. It just

    creates initial tables. New users get confused as to its purpose and when it should be ran Roadblocks new developers to the community This is a hard problem to solve because..... Tuesday, October 1, 13
  13. GOOD OLE DAYS Step 1: Code Change Step 2: Manually

    modify table Step 3: Deploy Step 4: FAIL Tuesday, October 1, 13
  14. Database change isn’t version controlled. When did we add X?

    Hard to tell what state the DB is currently in. Forgotten changes Errors with merging branches. Random SQL files FAIL Tuesday, October 1, 13
  15. THE PROBLEM Migrating data is hard and complex No consistency

    across projects (Multiple solutions) No definitive way to do this in the core New developer bootstrapping Tuesday, October 1, 13
  16. SOUTH South makes migrations easier, but not bullet proof. Currently

    the defacto option for Django Create an initial migration on app creation, then make new migrations on each model change. Demo Tuesday, October 1, 13
  17. Use schemamigration to create new migrations Use migrate to execute

    migrations backwards and forwards Use --auto to automatically create migrations --auto is a legacy flag back when migration files had to be created manually South introspects your models and discovers diffs to create new migrations Tuesday, October 1, 13
  18. ISSUES Issues with merging. (Sequence ordering) Migrations can take a

    considerable amount of time to run on certain systems (MySQL) Custom Django model fields don’t behave (TinyMCEField) Tuesday, October 1, 13
  19. Design issues Defaults must be added to all new fields

    When migrations fail, they fail hard. Must manually recover on some systems (MySQL, sqlite) Tuesday, October 1, 13
  20. ANATOMY OF MIGRATION Describes the entire state of the application

    in each migration. Incredibly long/bulky Inefficient When an app name changes... Tuesday, October 1, 13
  21. NEW FUN IN 1.7 Kickstarter campaign to improve South Raised

    well over the goal Migrations coming to the core in 1.7 and a new version of south for backporting Will be an upgrade path Tuesday, October 1, 13
  22. MIGRATIONS IN 1.7 Simplified file format. Just changes. Better introspection

    support Custom field support Support for all existing DBs that the ORM supports Consistency!!! Tuesday, October 1, 13
  23. MIGRATIONS IN 1.7 SyncDB removed! Only two commands, migrate and

    makemigrations Simplified process for developers Huge win for the community. Hottest topic at Django Con Not intended to support other ORMs Tuesday, October 1, 13
  24. TAKE AWAYS Always use south for your app if you

    have modeled data. Choose a good DBMS (Postgres!) Look forward to 1.7! Tuesday, October 1, 13