Upgrading Django (to 1.7)

Video in TIB AV-Portal: Upgrading Django (to 1.7)

Formal Metadata

Upgrading Django (to 1.7)
Title of Series
Part Number
Number of Parts
CC Attribution - ShareAlike 4.0 International:
Release Date

Content Metadata

Subject Area
Want to learn about Django 1.7 and how to upgrade Django? Are you unclear on what the numbers 1.7 mean or how Django rolls out new versions? Find upgrading daunting? Want to better keep up with changes being made in Django? This talk is for you.
Computer animation Information technology consulting Set theory
Beta function Gender Projective plane Letterpress printing Numerical analysis Human migration Arithmetic mean Different (Kate Ryan album) Authorization Quicksort Sinc function Form (programming) Alpha (investment)
Slide rule Link (knot theory) Lecture/Conference Content (media) Right angle Bit Whiteboard Metropolitan area network Demoscene Set theory YouTube
Point (geometry) Slide rule Beta function Length Multiplication sign Patch (Unix) Online help Rule of inference Semantics (computer science) Software bug Product (business) Revision control Mathematics Lecture/Conference Different (Kate Ryan album) Information security Set theory Physical system Alpha (investment) Addition State transition system Gender Projective plane Moment (mathematics) Counting Instance (computer science) Numerical analysis Entire function Process (computing) Right angle Quicksort
Point (geometry) Functional (mathematics) System administrator View (database) Multiplication sign Twitter Element (mathematics) Revision control Derivation (linguistics) Mathematics Different (Kate Ryan album) Atomic number Software testing Data structure Information security Set theory Social class Default (computer science) Addition Time zone Validity (statistics) Gender Rollback (data management) Database Database transaction Bit Cartesian coordinate system Public-key cryptography System call Connected space Human migration Quantum entanglement Process (computing) Computer animation Commitment scheme Blog Password Cost curve Video game Right angle Quicksort Library (computing)
Revision control Word Mereology Hydraulic jump God
Roundness (object) Gender Projective plane Endliche Modelltheorie Table (information)
Slide rule Message passing Focus (optics) Code Multiplication sign Quicksort
Point (geometry) Mobile app Code System administrator Execution unit Event horizon Software bug Coefficient of determination Mathematics Different (Kate Ryan album) String (computer science) Representation (politics) Software framework Data structure Endliche Modelltheorie Set theory Exception handling Authentication Default (computer science) Gender Projective plane Bit Line (geometry) Human migration Password Right angle Middleware
Point (geometry) Functional (mathematics) Computer file Multiplication sign Online help Field (computer science) Revision control Goodness of fit Mathematics Analogy Gastropod shell Endliche Modelltheorie Office suite Set theory Social class Physical system Inheritance (object-oriented programming) Gender Projective plane Electronic mailing list Database Line (geometry) Human migration Right angle Object (grammar) Quicksort Table (information) Directed graph
Point (geometry) Default (computer science) Forcing (mathematics) Cellular automaton Content (media) 1 (number) Database Field (computer science) Mathematics Computer animation Different (Kate Ryan album) Video game Right angle Endliche Modelltheorie Table (information) Error message
Greatest element State of matter Length Multiplication sign View (database) Numbering scheme Function (mathematics) Usability Programmer (hardware) Different (Kate Ryan album) Endliche Modelltheorie Physical system Social class Programming paradigm Touchscreen Electric generator Software developer Moment (mathematics) Electronic mailing list Special unitary group Radical (chemistry) Process (computing) Right angle Moving average Text editor Quicksort Reverse engineering Point (geometry) Computer programming Mobile app Functional (mathematics) Computer file Graph coloring Field (computer science) Element (mathematics) Operator (mathematics) Gastropod shell Authorization Data structure Symmetric matrix Default (computer science) Forcing (mathematics) Gender Cellular automaton Projective plane Database Basis <Mathematik> Line (geometry) System call Human migration Object (grammar)
Point (geometry) Default (computer science) Computer programming Slide rule Information Database Online help Function (mathematics) Line (geometry) Field (computer science) Human migration Shooting method Operator (mathematics) Triangle Right angle Error message
Point (geometry) Human migration Slide rule Multiplication sign Content (media) Right angle Endliche Modelltheorie Physical system
Windows Registry Group action Overhead (computing) Computer file State of matter Real number Correlation and dependence Software bug Revision control Mathematics Different (Kate Ryan album) Utility software Endliche Modelltheorie Set theory Mathematical optimization Physical system Default (computer science) Email Mapping Key (cryptography) Validity (statistics) Namespace Gender Software developer Electronic mailing list Basis <Mathematik> Instance (computer science) Human migration Data management Personal digital assistant Blog Right angle Object (grammar) Quicksort Reading (process) Spacetime
Point (geometry) Suite (music) Scheduling (computing) Mobile app Multiplication sign Software developer Gender Projective plane Line (geometry) Software bug Revision control Goodness of fit Process (computing) Computer animation Angle Normal (geometry) Right angle Software testing Reading (process) Surjective function
Principal ideal Point (geometry) Code Multiplication sign Motion capture Field (computer science) Twitter Revision control Mathematics Goodness of fit String (computer science) Endliche Modelltheorie Curve Software developer Projective plane Electronic mailing list Bit System call Human migration Arithmetic mean Process (computing) Password Blog Website Configuration space Right angle Pattern language
Computer animation Lecture/Conference
I'm I'm I'm I'm I'm I'm a lower-ranking everyone there may exist or use screening so make sure the mikes working at all so high I'm in Japan
come on half French have American freelance consultant from Austin Texas I I teach Django Inc. stop settings and perhaps most importantly as miles just told you that
I am the author of Django unleashed which is currently available in prerelease on safari books and is said to be in print form at the beginning of 2015 and start the book is all about is currently written in gender 1 . 7 and so I've been working in Django 1 . 7 in alpha and beta since January this year so fiddling with it I would say would know as much as they enter Godwin with the talk this morning only but I've I've got to dabble up and so this this leads us
into the following talk so the basically 2 things that I'm going to really try and talk about the 1st is gender releases of Django comes with all these numbers but what do they mean what were the useful for right so we what the meaning of the numbers associated with each and release how each release sort of created and how they are related and how this helps you figure out how you should go about upgrading run Django other morality gentlemen . 7 itself and we're going to do is we're going to build a project in 1 . 6 and 1 . 7 exactly the same way to try and look at the differences in a very practical manner and not use the thing if you or of migration or a
Django enchanter or else the old man
from Scene 34 of this talk is not for you right this is this is supposed to be a very beginner talk about upgrading and all of that and so if you are any of those things you're going to be horribly horribly board right so with that said what I do I like to put
all hold much material for my talks of online so you can go to this right now the slides already accessible but I have a long draft of an article with all of this content almost ready to go should be there within the next week we can know what that means is that if you don't wanna listen to me right here right now or else on youtube but you can go to this link and you can actually read the article in the nice relaxed setting because I'm going to do a little bit of a world . 4 here right so let's get started with Django
versions of right so every Django version has 3 numbers
that that would be a major number a minor number and a mike remember what is out way right away but it is not semantically version right there is a very strict set of rules for the Semantic versioning gender does not follow them at all of Django has its own very explicit system but notably micro numbers are incremented for a release for bug fixes were security releases minor of numbers are incremented for the addition or removal of features and see exactly how that works out and then major number In the documentation it says that major numbers or incremented for large backwards incompatible changes the thing is that in practice what we're seeing is that gender 2 . 0 is actually just going to be even version after Django 1 . 9 so this point they're just sort of associated with minor versions so now that a whole lot of meaning there to be a pretty blunt about it and so the thing to remember is that called locally Quill colloquially every hour and 8 Django version refers to a different minor number so when you hear sincerity different Django version at 1 . 7 1 . 6 right but what is the major number 7 is a minor number and 0 is the micro number there are also a pre-release there's entire pre-release system alpha beta typically pretty self-explanatory and release candidates not everyone is super clear on a release candidate is of just of release that is almost ready for production the API calls and features may not be modified at this time of and you are limited to body and security fixes so that point it's almost like you're already in release process to seperate the version numbers and releases from pre-releases what the changes were foundational to if they will add the letter ending number at the end so for instance 1 . 7 0 0 8 1 denotes the 1st alpha release but you don't need a 0 below remove it so 1 . 7 beta 1 that is the 1st beta release and this is the 2nd release candidate so the what is that all mean we now know what the numbers are and how does that help you well Django has to officially supported versions at all times and that means that there are 2 versions that you should be working with at the very least right that's what you want in production on your website deprecation happens in 2 versions now what this means is that the release that is really saying is crucial be the number thou shalt count and the number of accounting shall be cool right it's it's kind of important gender released of the deprecation specifically anything that is deprecated in 1 . 3 will still be accessible but with a warning in 1 . 4 but is totally removed in 1 . 5 so for 1 . 7 anything that was said to be deprecated in 1 . 5 still worked in 1 . 6 but is now gone right so it is worth paying attention to 2 versions back but the 2 versions the running so far so good at it was released yesterday by nice to be able to change my slides at the last minute and support prior to version 1 . 7 was 1 . 6 6 and 1 . 5 9 and notice is not using the micro numbers those patches you should always be on the latest patches there is no reason not to upgrade the ladies patch and so 1 1 6 . 6 1 . 5 . 9 but with the arrival of 1 . 7 we saw bonding in all of the available versions so 1 . 7 brought the arrival of 1 . 6 . 7 and 1 . 5 . 9 except that 1 point 5 is no longer supported right you don't actually want be running in 1 . 5 anymore it's not going to get security releases get any releases it's considered done it's over a long yeah there's a catch right there 2 versions but there's also the long-term support Django of the project that allows itself to tag certain releases in certain versions for long-term support and what that means is that they will support it for some length of time LTs for 1 . 4 is set to go to march of 2015 and there is some back and forth over whether the the support ends there they continue to support it so I'm not really sure but my recommendation would be if you really want be thinking about 1 . 7 or 1 . 6 but we'll come back to that in just a moment now that we understand what the versions are with the version numbers mean we can talk about the
previous gender versions this will help inform us about 1 . 7 and the upgrade process right so the obvious thing is
that you know what I'm not 1 . 7 and 1 . 6 is is currently supported so we wanna know a little bit about those but what we find is going affected application process and point 7 so that's still important and 1 1 4 of course is actually supported because not yet so it's a with gender 1 . 4 entanglement of war started off with times and support right that was that was the big new thing it's all couple additions to the war and such as prefetch related and big deal and but also some really basic stuff like cookie-based session handling that and that only came and went with and all security passwords prior to this were stored all ensure and this was when we solve the public key derivation function to come in as well as the crypt that's that's huge right for security that's that's a major and and the cost function across testing and a new structure for your folder into what 4 was was pretty massive and it's also why for LTS 1 . 4 is arguably I'm not sure uh everyone would agree with me on this but this is arguably modern Django right it's it's sort of the beginning and getting a couple shakes in the sense that gets which is why so this is March of 2002 at 12 and so in February 2013 we had gentlemen . 5 general what I felt like a much smaller operate right so to modify a python 2 . 5 was dropped and so you had been 2 . 6 to 2 . 7 and was experimental support for Python 3 the you could try it it was recommended it was more like a test this out to the go on we saw the custom gender USA and of the function-based views that had been deprecated in 1 . 3 were completely removed in favor of the generic class these views which currently exist and which I'm actually you try and despite anything else so of itself kind of small but you really wanna pay attention to that and that Python 3 support that actually a huge deal and was all lot a lot of work on now the thing about 1 . 5 is that the upgrade was nonetheless still really tricky and the reason is that there were mandatory settings in deployment and we weren't always obvious right it wasn't always obvious when you went to deploy what was going on when it aired like crazy because you need it use time-zone allowed host you need to make sure you have a secret key otherwise it would not and this is this is actually kind of important because this I think uh you have that's Russell and but I think this this may in fact be the reason they actually have the what is originally validate command and what has become the check command and 1 . 7 so pay attention to the settings will come back to it but which then led to 1 . 6 1 . 6 was huge right so I'm still 2 . 6 but Python to support was not totally official and we had transactions completely redone and spearheaded by illegally stuff and so transactions had been changed since version 0 . 9 and suddenly you could commit database changes of the was the concept of atomicity vise decorators and then it was fine grained rollback between safe points if your database supported it elements and persistent connections finally settings got super easy if you're a beginner and Django when you show up in 1 . 6 your life was incredibly simple compared to all the previous versions there was a vaster in settings which was lovely of the SQL like a database was now a default admin was turned on by default and so was clickjacking was so that that was super super call this is where only the hand we also see the validate the this was to try and help with with figuring out basic setting differences what was wrong and it was it was a nice step right it gets us where we wanna begin 1 . 7 and the only trick was was that we give great here if you done funny things with transactions you were you were in trouble and but the other thing is that we see the beginning of a trend where gender begins to remove a lot from the contribute library right this is where comments marked down and Local flavor really get sick of that leaves us with Django 1 . 7 out for those who missed it this was what Russell wrote on the gender weblog right before selling this T-shirts which he's wearing today by the way if you can catch Russell that is that is in fact the the teacher results all and so it's kind of a big deal and these are some of the features right and would have focused mainly on those top 3 because that's what we've got time for a long time this was release of course yesterday so this way toward toward and I wanna try and take her to people who were just a little bit afraid of migrations there's nothing to be afraid of their fantastic you want these get excited now i haven't put the Python version on here and that's on purpose Django 1 .
7 requires Python 2 . 7 it's going to be may be the most difficult part of the new requirements for this version so of course my country is still supported and thank goodness but if I could affect could really get this to be the 1 thing you take away by Python 2 . 6 is no more it has ceased to be it expired and gone to meet its maker bereft of like a recipe so this is an ex Python don't use no really just like about you to take this
is like the word of God from here right if I could get 1 thing please please and really consider upgrading to Python 3 it's going to be really important pretty quickly with that so let's jump
directly into building a project in gender 1 . 6 and gender 1 . 7 so we're going to build a project called cannot what we're going to build an act called round table and we're going to build a nite model and what we're going to do to demonstrate of the 3 key new features is that we're going to take her nights were Greek really really really basic model and then we're going to be big trade by Lance a lot so we've been asked by King Arthur to build this up and to get the information out there it's good publicity so again these are the
3 things were really gonna focus on and the rest is really really cool you should take a look at this is what we're looking at right now now that the reason for that is because
this is the total rabble there is so much here and it's really really cool but this
is what we're going to end up like if we spend true much time here so this is a whirlwind and the UN would show a lot a lot a lot of code the code is actually not what's important in the coming slides I've put it there and in all its glorious detail so you can download my slides you can go to the article the article actually has more code so you can you can actually go through more slowly with much more important is sort of the philosophy and the workflow that you're going to see me go along right so that's the focus and the code you know come back to it but without have a 1st pass so let's start by creating a
project you guys all done this and and so the 1st difference is that in general . 6 you had django admin and there is now a nice alias so that you can just do django admin but without the dog pi on the structure of the folder looks almost exactly the same the only difference is that in settings there's a session authentication middleware i which will invalidate existing settings in the event user changes the password which is super cool and then there's also in the Urals 1 small change there's a line missing it's admin . also discover it's gone now and still enabled by default but this is major foreshadowing for the new Act framework come back to a node is going in a 1 . 6 framework as 1 gender 1 . 6 project but we normally the best practice would to be allowed to run sinking right right so just as that that when you doing some . 6 following long runs in now also at this point you can create the AP in both genuine . 6 and 1 . 7 and it's exactly the same with the exception of 1 . 7 you automatically get the migrations package right it's it's in bold L now we can go about creating a nightcap out so there's a little trick here which is that this would be fine right it's a nite model uh yes no not nite after nite model of and it's very straightforward we have a name and then we have the string representation for Python 3 right this is Python 3 and the problem is that doing this in South were doing it with South 1 . no which actually introduced a regression so that you can't actually currently running Python 3 so gender 1 . 6 is going to run even of heaven to imagine going . 7 is going to run in Python 3 and and so we have to do a little bit of shenanigans to get it to be running about on the future import unit code literals make sure that everything runs in new coordinated strings are now unit code and then we have a decorator which is super cool because in that this string representation in Python 3 is stir but in that to its unit code that decorator ensures that it works in both right and about the bug in South 1 0 there is already a bug fix for it it's just simply not released and this seemed like fun so now that we have a a project we have an
app and we have a model we can go directly into migration it's right so the history
migrations you heard a lot about this morning just to to recap and gardening created south in 2008 it quickly became the defector tool for schema and data migrations up and in 2012 and again asking around about the API for self to worlds migrations in Django heated started in March of 2013 and he initially set a goal he he was avoided it's is very modest about this this morning he initially set a goal for 2 thousand 500 pounds at which was met in just over an hour of this stretch schools which had a maximum of of 7 thousand followed like several days later and they continue to 7 thousand 950 2 pounds which at that time in dollars was 27 thousand 397 that's that's a lot of money for this and it's it's actually really good things happen because migration called on what is a migration so I'm sure there's some people in here who maybe have avoided sound you have little project you haven't had to use it and the way to think about migrations if you haven't seen before is version control for your database schema it's not a perfect analogy but you know there's all sorts of problems with an analogy special because you're putting your version control in the version control of that's going to get ugly but the bottom line is that it helps us that you don't have to make manual changes on your database when you make changes to your models right super helpful and workflows here is that you were going to make attention model you're then going to create an migrations file some way of C and then you're going to migrate or alter the database using the instructions in your migration from so we sort of did all that in 1 . 6 and 1 . 7 so now we can focus on just 1 point 6 right so again we created project we are added to settings up I we then called sink DB and then we created the at right so we already have a database at this point but everything else should be fairly straightforward so which point we call schema migration initial we tell it is the 1st 1 and a goes ahead and says 0 hey gallon just don't look here models in great migration of that migration file looks like this right there is a class and there are also 4 things were were really only interested in this 1st 3 the forwards method the backwards method and the 4 models which are referred to as personal so the forwards method is just what gets called when you tell it to change your database right you can see it's just creating a new Table there is no magic here and the backward is the opposite right it's it's totally symmetric to forward and so just deletes the nite model of so the we're want to that's fairly straight for the weird 1 is models right is referred to as the frozen model and it's not immediately apparent what it does this is just kind of sitting will come back to it once we have ah migrations we can just say hey please apply this and it goes ahead and does just that you'll notice that last line installed 0 objects from 0 fixtures will that's super helpful but you know we got King Martha it's it will it be really nice if they could download this from the gate rebuild and immediately know who all the nights are also so we can use this initial data system with fixtures to go about and had doing that so we are going to pop into the gender shell we're going to create a whole bunch of nights we make sure that the there and then to make sure that everyone has them we're just going to use the dummy data function were going to slam it down into adjacent file and we call initial data Django already knows to look for that and so if we roll back or database and the reason we can do that again is because of backwards right it's just going to delete it and then roll it forward you can see that it's installed the 7 objects which means that if we include that with our project everyone will have the list of nights that's great King Arthur's having until and lots
damn it let's say OK so offices of as well I need a new field and I need you to
our to deal with life on the database as you go from a problem so you add the field and then you say hey I'm a to automatically figure out what the change in my models and stuff goes on a problem and what it's doing is that because it can't rely on the content in the database right it is actually know what's in there you can't trust within their so what it does is it looks at what's in the models and it looks at the frozen models and it does the difference between the 2 to figure out what's new and so now I know the purpose of the 1st and the so we use this to automatically generate now I intentionally left and error over here which I forgot to mention when I brought it
up on the Boolean field but should have a default as of 1 point 6 you need to have a default equals false I intentionally leaving it out right so fast forward and so when we call roundtable although cell tells us that it doesn't know how to fill it in but it doesn't tell us as a problem right so what I've done is I've simply said 0 will by default no one's a traitor right force at which point we cannot migrate around table and you think everything's where work just fine in your right what happens is
Django puke state at you to be crass about it and it's just going to start really really complaining what's happened is you've tried to load the J. and doesn't know what to do with the traitor feel right the initial data doesn't have it and so gender just freaks out of which is good that's what you want it to happen in the sort of implicit behavior there could really really dangerous but that means that are initial state of problem the initial data system is a problem when used in tandem with migrations so let's step back
we're going to get rid of the migration file that we just created were going to delete the traitor field are going to deal with this problem 1st was roll back the database that the force command we're going to move the initial data so Django doesn't look for it automatically and going give give it a funny name will see 1 moment and then we're going to reapply the 1st migration so that we have the structure of the nite model in our database but not any data in right and you can see that the bottom it says installed sir objects from 0 fixture now this point we want something like the initial system but we don't want the initial basis for gonna go ahead and create a n n I data migration and the data migration is simply a migration frozen model in all except that the forwards and backwards are not implemented right you are expected to write these functions and this is where it gets really cool right because you can rely on the fixture court system right knocking at initial data system you can rely on the fixture system and just call it directly and say hey I want to use that Chase on file that we still have and that's in fact whining that so that you can help figured out the thing is is this is pretty silly right you've got to files basically to generate data in your in your database and you can do it all in 1 now you can see that that's better look quite the way it should and notice that there's an ORM before the nite the thing when doing the migration is that you don't know if the models in your database or what she wants right so South will create the historical model and put that in the or so that you can then use that to actively and correctly give it what it expects so that's why there's no more and and that's a big thing about the new migrations as well which we'll in just a moment so now we roll that the database again we bring it all the way back up we see are initial schema is now applied and we see that are our initial data is also needed to ensure that the data generation process is also applied and so we have everything that we want now we also want to program or backwards because we're good developers and we want this to be symmetric right and so that's very easy reuse or an and nite again and is able to everything in the database right everything we decided just fantastic and what this means of course is that we can actually roll back right we were in 0 0 2 4 0 0 0 2 are now going to 0 0 0 1 and at this point you know we we go into the shell and we ask for all the knights they've been removed right so this is this is really cool because you can move backwards and forwards in the migrations either adding data or removing data and this is the cyclic do at this point now that we have the data we want in our database correctly without any reliance on the initial this system we can go back and add a traitor field it's still wrong on purpose we get exactly the same output as last time when we try and automatically generated and so we're going again say it's false everything is default force on and then we migrate and everything works just great right and that's what you want right so at this point what we have the new field in there but the problem is is that if you going to shell must've length what is a traitor which is really the original point here and bits as false and then north is not happy with that so you go ahead and create another data migration you then fill in forwards Viet again we simply say um the you know or a nite find Lance lot 2nd to trader and you remember to save the backwards right again because we want this to be as much as possible the only difference is that were not saying intervals but so few migrate all the way up with our forced migration yeah let's look is now trait and authors happy now that's doing all the kids so how could such excited on so I again in 1 . 7 we do need any those beginning shenanigans right you just start the project you get into the project you create an have and then you can immediately go straight to programming models you don't need to worry about seemed to be it's far away from the Sun so this is exactly the same model as we had before but just with the name right the traders gone were at the very beginning this project and we can go ahead and instead of schema migrations were going call make migrations out the outputs really really pretty you can't see it on the screen as a kind of the the color coding to work but in my Bash terminal it's color coded gorgeous out so at which point it will create this guy and this is totally different right there were 4 things molested might in the last migration for South and this when there only 2 dependencies is at this point an empty list right so if you heard kindergarten talks you know what's coming on the that front but what we really care about our operations and the operations currently looks like this and you can see what it's doing is it's creating a model right it knows that it's going to create this in the database you'll notice there's no backwards right operations historically forwards would super cool about the new migration is that they figure out automatically what the symmetric of opposite ease and don't think that's probably the right market sorry element now without migration automatically figure out we can call migrate at which point it will migrate everything that we need including on the 2nd last line arg roundtable act and at which point it should come as no surprise that initial data no longer works right it's been deprecated in gender 1 . 7 because it doesn't play well with migrations and so at that point we are forced to use data migration right and that's super-easy except instead of asking for data migration recently going to ask for an empty migration files so we go ahead and do that and that name is horrible that is that is so unhelpful so I don't know this is standard practice because I don't think it's been around long enough for there to be a standard practice but I can be meaning these and because that's that's the time and date that supposed to be created and that's not interesting it doesn't tell me anything so I'm renaming to at nite data at which point we come into here and and we need to feel a sense so as major mention this morning there is a really hopeful Command called run python which takes essentially 2 things the forwards method and the backwards method so it's very similar to self right it's what we do going forward and what we do going backwards and so here what we're gonna do forwards add 98 data when we go backwards were going to remove an idea and the 2nd 1 is actually optional you need to put in the reverse code keyword on and just like with cell we could rely on the fixtures right the initial data system is gone but fixtures sparked Wright-Fisher still work just fine if you want them and need them and there's so projects that are gonna make really good use of them like class the class-based views makes it has a really good example for how use fixtures and so we could do this and again this is pretty silly because you now have 2 files for 1 thing and so I advocate come with absolutely no basis and the the act of doing this now is a slightly different right ax get model roundtable nite who it's the new Apple but we're not getting it from gender directly you'll notice is being passed into add nite data which gets an apps and scheme and so Andrew talked this morning about the schema editor it's basically what does the actual database altering and manipulation but the acts is the historical right is not what is currently in your models it's what but the new data migration are the new migration system expects there to be in the model and that's actually really important so when you do this you wanna make sure that you're pulling from apps otherwise things are going to go completely that's on so we then go ahead and treat everything as we would expect and again once again because we're dedicated to being symmetric and the programmers we go ahead and do remove my data and again you can see me using the new app that loaded and just doing all of them and we get to relive plants a lot of
betrayal at this point and so we
add the traitor field and you'll notice again I'm intentionally making an error now here's the thing before we look at migrations let's step to the side we avoided the mind managed up I validate bullets when Shaq who it knows there's a problem it warns us there's a problem and in fact it will tell you when the docks to look to figure out how to fix that that's really cool but what if you forget to run check will Jaggars got you covered because when you run make migrations it'll run check for you and it'll yell at you right to you all the same information which i've hopefully removed from the slides you can see the rest that outputs and i which which is as saying exactly like South what you want me to fill it right so it's going to warn you but if then also the say hey we can keep going forward and you could you could say 0 well you know the default is false in and just kind of keep going of if you haven't listened to check so far it's going to keep yelling at you right when you migrate it's going to say hey you to really really really don't want during its own so the bottom line is that triangle will let you shoot yourself in the foot don't right don't shoot yourself in the foot when Django checked once you that there's a problem there's a problem so do pay attention to the output of these comments right don't just gloss over them because it's in the now incredibly helpful right so of course we're going to pretend that we did have make migrations and then migrate we're going to add the default false we will then go and run make migrations will get a correct to make migration and we will then migrate that but I mean it with the same problem as before where yes we now have a traitor field in our database but let's a lot is still not labeled the traitor so we once again making nt migration File instead of data migration and we can rename it I think again not clear on that alone and so that we can then I invoke run python as the operator and we will programs that Lancelot status to go forwards and unset Lancelot status to go backwards so the set lands lot but now what's set lands that should read set Lancelot trader and onset Lenz's traitor and so that's set Lancelot trader and again we're using the new Apple our and we set it to true and the onset is exactly the same thing with the the applica and all of that except that we set to false at which point we can migrate this new data migration at which point landslide is now a filthy dirty traitor wow OK that was
a lot of content we yield quick where am I going that's right what's the point let's review what we just saw right the 3 D features so the 1st were
migrations right this is the big thing it's what to take away and hopefully you're a little less frightened right it's there to help you it's super easy all and and so you wanna you wanna like really I take some time and all drawn I have an hour OK what is broken there we go only so far have high and so the initial this system is deprecated right it should come as no surprise given our last example and or fixtures still work tho however right the 2 were related but not the same and and frozen model is gone this slide is shamelessly stolen from
engine Godwin because he used in his last 4 5 presentations and and it shows you why the frozen orange gone right it's takes up a lot of space and 1 of the big features of gender 1 . 7 is migration is that you're supposed to be able to edit them right this files were very small and went directly into them and we had no problem fooling around right because they're very straightforward so the historical model right
uses the apple over to build it directly in memory and keep it there and that helps see the utility of the dependencies right every migration has a set of dependencies which then uses the applica to build this historical for which he gets to act on yeah but there's an important coffee which is that when you were using these of the methods you define on your actual models will mark it used to be very careful so if you've overridden save and you try and use it in the historical models in a data migration it will not work it's just going to call the default on there's also currently a bug in 1 . 7 or and call it but it's a problem but where if you have tons and tons and tons of models it's going to freak out it's just when you take absolutely forever there's currently a uh but the being there's a the tracker and they're looking at 1 . 7 . 1 to try and fix the problem on but the key takeaway migrations among . 7 have exactly the same workflow as the migrate as South migrations right change model acrylamide of migration file and you apply the migration and and that's really cool because if you use them for himself there's there's no real overhead right so about south and 1 . 7 South does not work in 1 . 7 right if you're in 1 . 6 using some migrations adjournment . 7 year using native migrations you can't sort of over swap to our overlap to us and if you run himself the instructions on the dock and they're kind of hysterical because it says Bring upwards migration and creating new native migration deletes uh you just and so uh because gender knows not to use South it knows the difference and so the south as of version 1 . 0 I'm but just in case you wanna keep around the 2 settings both for Django and for south so that you can help avoid any sort of namespace conflicts if you need it you probably want now if you don't migrations all I don't know why you would migrations all don't follow this advice all right like don't get rid of them of which you can and then you know naturally to this on those is with the applica so prior to 1 . 7 it was called the AC and and governance blog referred to it as the board at because it shares the State across every single instance of it and it's totally incompatible with migrations and because migrations needs this historical models to act on right so it was 1 of the 1st things ago given migrations was going to come up and it led to the new map registry out basically this is been becoming coming 1st since 2007 it's been worked on by a ton of people but basically I'm under the impression that migrations of what finally pushed over the edge when in May of 2013 and goblin began to change it so that migration work in the group in December 2013 picked it up and took all of the work that had been done reduced to just 7 items and then focused on 3 it's on the developer of the Google developer mailing list it's incredibly good read I really recommend finally there was the systems check out the system checked I really think that have I have no basis for this on that has to do with the 1 . 5 upgrade where we have problems with use cheesy alot host and secret key this is going to seriously help anyone do any upgrade avoid any kind of pitfall for all of that the work of for 1 . 7 was done by Christopher drug and overseen by Russell keep McGee and basically they took the validate which was a little confusing and totally monolithic and turned brought it out into a whole bunch of different pieces what it means that you can actually use the check right this is from documentation you actually invoke it directly so that you were performing checks on your own stuff please do there are a couple other changes I just wanna talk about and there's some the corre said you can now set as a manager you only have to define agrees that rather than overloading both agrees that and the manager and there's a new look up system and there's a prefetch objects to help with related but there's a talk tomorrow at 10 30 am and ballroom 1 with christopheradams about learning to optimize Django with prefetch related I think it's unfair to expect any sort of coverage about the new prefect object but it will really help you get to the place where you might understand the object better and a really like to tell you that
preparing to upgrade revolt involves something
on the line of the upgrade process however is fairly
straightforward right if you look here dependencies and you figure out what you need upgrade well if you're 2 . 6 you don't wanna be on onto politics anymore you wanna go straight to 2 . 7 on third-party apps are they still supported or they still working for you or they helpful or you 1 the latest version is there a version for the next 1 right you then take the release notes for the version for upgrading to and you just go through it it a tedious process but it is the safest way to go about this because you hate everything right at which point you run your test will if you don't have a test suite unpleased by Harry Percival's book it's a really good read nodes of fantastic and it will be super helpful please have a test suite it will be so helpful out now again this is a tedious process but it's not the worst thing right everyone says is the worst thing but please take the time to do it and in fact schedule right 1 of the big things is that you really need to think about this this is now you know there's a release schedule you should expect this to happen and upgrade early upgrade often if you have a lot of little operates to do it's way better than having to do 1 . 1 all the way to 1 . 7 you should not be running 1 . 1 right at the very least you should be able to work on our and you can start operating at at the release Candidate right was a release candidate out this angle this is mostly good enough and that way you can actually help the gender project by providing bug fixes if it isn't working for you out the final thing is that I I think people look at this wrong right they say all we have to like schedule all this time to get upgraded no you have to invest 2 weeks on Monday to get hundreds of hours of really good work from hundreds of other developers and and people really need to start looking at it like that it's a major investment yes but the return on it is the norm it's on and it's getting a little
scary but so this is what so this so this is how long the the each version was the principal version right so 1 point 6 had 1 . 7 made the May 15th release date would have only been around for 190 days and you can see that curve is pretty terrifying now they didn't make that right this is this is what the actual was and that a little bit more reasonable but you can still see a trend where they're trying to have shorter releases so it's going to be increasingly important that you stay up to date right so it's really some knowledge general point 7 means
the death of 1 . 5 get off on and it's not on LTS support it's gone and if on 1 . 4 and saying 0 we can sort of stick around will remember that it might be over in March of 2015 that's not all that long right baby might decide to extend it but there's no guarantees so really consider an upgrade up to 1 . 6 now why not 1 . 7 1 . 7 0 depending on what you need might have a few kinks to work out which might which look like they're all going to be sorted out in 1 . 7 . 1 if you can get to 1 . 7 please do right but if you have any merits project with the models at that are completely not take it slow right finally us so we've talked about iterating through each version so that you can do that the release process this will help with gotchas 1 of them is that you know the passwords of the password euros and 1 . 5 base 36 when you get 1 1 6 it's be 64 but 1 . 6 knows this that's it catches up so if you do 1 . 5 directly 1 . 7 it doesn't capture and that's going to be a problem so you do 1 really take the time going through each version at thinking he is dead long live migrate of initial data features are dead long live data migrations and remember that when you're dealing with all this other fields need to construct own it's also important to look ahead to the future relies on string on time here I'm sorry there is a deprecation release of documents on the Django web site it will tell you things like 0 you're all configurations are going to change in 1 . 8 there will be no patterns it's just going to be a list of calls to URL you will need to use direct imports knowing that can help get your code right before it's even released so it's a really good idea look at it and I'd like to thank the developers who documented all of the changes in the raw wrote a fantastic female out Russell wrote a friend fantastic said he knows about the changes in engine Godwin documented all of his stuff on his blog it's been made sure way to read and I really hope that the other talk about the DP is like the Python Enhancement proposals but for Jango come along because the documentation and it would be even better questions do we have time at
thank you wouldn't want to this in the this is the end of this