Stumbling Through Django and How Not To

Video in TIB AV-Portal: Stumbling Through Django and How Not To

Formal Metadata

Stumbling Through Django and How Not To
Title of Series
Part Number
Number of Parts
CC Attribution - ShareAlike 3.0 Unported:
You are free to use, adapt and copy, distribute and transmit the work or content in adapted or unchanged form for any legal and non-commercial purpose as long as the work is attributed to the author in the manner specified by the author or licensor and the work or content is shared also in adapted form only under the conditions of this license.
Release Date

Content Metadata

Subject Area
If you’re a beginner about to embark on a new Django project adventure, this talk is for you. When I started my first Django project, I took the “Sure, I think I can figure that out” approach, which is fun! And also dangerous. But exciting! And also horrible because I caused myself a lot of trouble and barfed on my keyboard. (Metaphorically.) Oops. My hope for this talk is to pass along lessons I learned the hard way, and save the world. Or at least prevent some frustration. :) We’ll talk about version control, structuring your project, and how to handle top secret stuff. We’ll also talk about throwing house parties without causing anaphylaxis, pregnant daddy seahorses, velociraptors, and friends. I promise all of that is related to Django.
Classical physics Axiom of choice Random number Group action Multiplication sign 1 (number) Analogy Set (mathematics) Chaos (cosmogony) Mass Product (business) Mathematics Virtual reality Different (Kate Ryan album) Analogy String (computer science) Gender Software developer Classical physics Projective plane 2 (number) Bit Cartesian coordinate system Causality Computer animation Video game Right angle Musical ensemble Virtual reality Near-ring
Pulse (signal processing) Installation art Code Source code Disk read-and-write head Web 2.0 Medical imaging Virtual reality Different (Kate Ryan album) Analogy Endliche Modelltheorie Local ring Monster group God Source code Arm Broadcast programming Software developer Virtualization Bit User profile Type theory Web application Arithmetic mean Message passing Right angle Quicksort Freeware Virtual reality Data structure Monster group Functional (mathematics) Mobile app Inheritance (object-oriented programming) Computer file Tournament (medieval) Mass Number Revision control Profil (magazine) Googol Integrated development environment Message passing Mathematical optimization Task (computing) Authentication Addition Gender Projective plane Bootstrap aggregating Computer animation Integrated development environment Personal digital assistant Query language Blog Revision control
Point (geometry) Dataflow Server (computing) Computer file Code Multiplication sign Electronic mailing list Branch (computer science) 19 (number) Graph coloring Revision control Proof theory Internetworking Computer animation Integrated development environment Velocity Internetworking Logic Password Right angle Physical system
Group action Scripting language Multiplication sign Execution unit Set (mathematics) Function (mathematics) Variable (mathematics) Mathematics Virtual reality Different (Kate Ryan album) Semiconductor memory Limit of a function God Scripting language Email Software developer Stress (mechanics) Bit Variable (mathematics) Measurement Connected space Proof theory Message passing Process (computing) Frequency Right angle Escape character Figurate number Virtual reality Row (database) Point (geometry) Functional (mathematics) Perfect group Observational study Spiral Branch (computer science) Online help Product (business) 2 (number) Frequency Internetworking Energy level Integrated development environment Data structure Address space Mobile app Key (cryptography) Inheritance (object-oriented programming) Gender Projective plane Plastikkarte Database Denial-of-service attack Word Computer animation Integrated development environment Personal digital assistant Password Exception handling
go on and on and on
and on and on and on and on and the day and all the
time and I developed so nervous he come down everything that you find in no wires the worry I have my name is melody I I'm a new gender developer do you that thing with the there's just enough trips per enough to cause trouble the I got to so I will be asking yourself when I'm listening to this person who is not super fancy pants I I don't know how you make your choices friend is quite possible that your lost and looking for a doughnut I but if you're here for GenGO or for doughnuts I know what I want you to get out of this talk the the yes not too long ago I was diving face and brains 1st into my very 1st Django project on there was a lot of chaos and confusion and carrots I therefore into the character but I really like alliteration on but it was just kind of swirls of expletives and face palms in general madness and I made some big costly mistakes on and it turns out that those are a decently avoidable set that's what to give you I want to lay out the be by the postmortem of all of my flailing missteps so that you may avoid crying on your keywords and vomiting on your were products are not that I did that but that you might I don't know you on here we go the it during house parties without causing an influx which gender said solely normal the life of the recommendation to me was to create virtual environments of which I dismissed immediately because if I believe in anything I believe in laziness i and find the change because science and the and that the people goes over not under because I'm like a decent person right now and I also didn't totally understand what a virtual environment was or what it was going to do for me and I certainly wasn't going to UN lazy myself for no good reason so let's take a look at that Our quick note this is a rather long analogy answer just pretend that you will love long analogies especially the ones bad drawings encouraged Berger of so let's say that you have built it's big and beautiful house and you've made it with a massive living room the living room is actually I can tell you love this trying I can feel it from your heart of often at I the the living room is so bad that you have bothered to make other references like this we living room whatever that now I have some friends that want to host a party at your house and you're like ideas in my living room it's amazing of course I can do that and so you tell them what your friends tell you what they needed for the party they need classical piano music they need to have some which obviously on and very critically they need there to be no peanuts because every last 1 of them is terribly allergic you can give us everything's fine there comes a 2nd group of friends and they also want to have a party in your mass of living room and you're like I can it and and they're like we need classical strings music I think that's right any Turkey legs also find and many bottle rockets because they're weirdos apparently whenever I use still say everything works fine another group comes you know what we we're not there yet but were saying that it's fine everything went well RIRs going skip over how well it when it was awesome everyone wept with joy the next the problems they're like me Tolimir party near like obviously amazing others RT to here in ever and having a good time and had this party in other places before bring all around stuff readers level the thing right however it turns out that while you were looking they took a whole host of peanuts and threw them everywhere and 1st group instead of so bad enough that they are in axis for I still how this relates to check out of thank you very much but thing that the 1st group is your 1st project right can now have a good time for you put in a 2nd project also 5 make it a little bit different right but not so different that they can't get along on the
3rd project no maybe it has a different version of Python a different version of Django and once you install the requirements file your 1st project just blows up number I am and this brings us back to virtual environments the logical solution for throwing parties without becoming a mass verderer murderer by peanuts is to build rooms right you build the realms you stick each party in a different room and no 1 cares each other that's like optimal for throwing parties just in case I have a virtual environments to the same thing for development you can look this up in the I mean but here's the quick basic funded and Python 2 there is a package called virtual and that we install it should install virtual and and then whenever we want to build a road built environment we say virtual and and the name of the environments on obviously in this case penetrate because of the murdering I'm in Python 3 this is built and so we don't have to install anything extra we just take Python 3 5 dash and the and the full of peanuts and it will make capital environment for us and you need to activate the environment otherwise it's just like going back to the living room and it'll just grab whatever you have installed on your system and and so to do that will type source the name of your projects last then flash activate and when we must enter it shows us that we've activated at the environment by putting it the name of the environment in parentheses at the beginning of now there's 1 tool that although it involves installing a different thing which interferes of my laziness in actually enables additional laziness later so started using it exactly so it's called Virtual and effort I mean we install at with Capon's solver to improper just like we did before then my gosh we have to take 2nd step by adding something to our bench profile and you can look this up also the documentation for Virtual and Rapid later but this is what it looks like for my gosh it's so much it's 2 lines and but all this allows us to do this later on we just typed in capital and in the name of the environment To make a virtual environment and that it automatically when you make it activates it for you as well so you don't have to do the whole like source lumber whatever that stuff was that I said on later when we want to work on it we just have work on in the name of the environment and it activates ports I did you forget the name of your environment of course you get I here human person just work on press center and it tells you all of your environment mean after all their attention yes our next the say notice the monsters and yes to pregnant that horses with gender the Our when I started my 1st in project but I under solves understood myself to be doing was building a web app right it's and now there's 1 you're building 3 go got so when you're looking at the commands that we use to create edging aware that we use our project on and then we use start at which is obviously still kind of hear web that I think we watch so in my mind we started a project on we started 1 of his only making 1 at rates and like this and and then we're edition of everything that happened in the US why would you make more than 1 as well there are lots of things that we typically need to do with project In 5 of my tiny bit of project I have to store a collection of images that I carry it on I have to store messages that users and hurt and I have to schedule and send messages providing this functionality requires a bunch of models and using other from stuff and if I tried to start 1 and only 1 out this starts to look a little monstrous and you have 1 file through your models you have 1 file free reuse and everything just gets like bigger and bigger and was that out when you go back to find code for a specific thing that you want to adjust its just kind of like miserable task that looks like that and makes the dream of scary things so we use apps to avoid that's arm but we don't want just be like this is not the amounts owing to make a new happened just it's like whatever on you want to do is think about each thing that your project needs to do and make a separate out for that so with file
that I started out with everything all jumbled into 1 app called by the creatively I but I eventually transitions to have an app for curated messages on and after a custom user messages and after sending messages as well as this authentication paying that I made I ran and I accidently named it s you off profile of men and again I so what we've done is instead of taking a BBC verses and gluing them on the death of like head and neck and back in the here's a a have tails going it on the tail of we've left them as their own little adorable things and put them in the protection of Danny seahorse on the here 0 there's a happy in but decided on this I decided on this analogy before I Googled whether daddy seahorse looks like and 0 my god it is terrifying like it's the stuff of nightmares don't do that you the a protecting your Velociraptors with JVM so in my voyage to my 1st a project I came across this blog post sorry from the red the blood posted from a tournament so you don't get credit for half discounted at but anyway the 1 only to save all my sort of pulse locally and so this means that when I was using bootstrap in addition to linking to the city and I would download all the CSS files and all that other script and save them nice article recalling that I'm excessively lazy this is not like something I wanted to do surely that was at least 2 more steps no thank you on and what why would you do this allow me to illustrate my disaster and let chemist really amazing G query thing that does something also something possibly like
this half the stuff that's amazing and then we also there's like a ton of really useful reasons support velociraptor neurons I w pretend the and anyway my finger like a modal which is way boring and of the have any dinosaurs in it but anyway so will just pretend that I did the dinosaur think about anyway so it is the thing right I got a coffee shop to continue working on my amazing things and I I don't know the Wi-Fi password in like the Bristol it's really busy in it and 1 of than and so I thought to myself hand working in in a local environment I told you need the Internet Internet doesn't allow me I the and that's Williams you anyway I I started my local server and they good at all like 1 2 7 whatever it is only to discover that my velocity vectors color and everything like 1992 which was not new thing here I surely I have done something horrible right because I'm a beginner and I've done numerous horrible things at this point so I just start ripping apart code that's logical right digging through everything and changing random things and like I don't know I been something up let's burn everything there is a lot of ripping apart so eventually I decide that I need to google lists right that's the tedium so I government but the rest of the wife password i up like I look up like 1 thing and then go and refresh server and my beautiful velociraptor meets me again here is enjoying it at and that's an eclectic but the only thing that was happening was that because of my lack of Internet I can access like CSS files JavaScript files anything the matter files on and that's what happened all of my independent from Internet was alive if I had saved those files locally I would have had that problem right to take up which brings me neatly to my next topic terrified abandonment of drug full mistakes in Django on all this was happening on the 1 and only copy of my code Weinmaster branch and a and then remember that lady who was the 1st is like and resource that 19th century fresco G that's something my product and like there maybe a new piece of our about like maybe we both should have made a copy for it at the
end of the and then we recall homatropine upon anything this quite a bit and while my renewed internet access solve my velociraptor problems on the floor after the proof systems and here at anyway if it didn't solve all the new problems that I had created because I had gone so far down the rabbit hole and fixing nonexistent problems and I had no idea how to get back to where I started this is not great and I honestly don't know how I got back to where I was just kind of like a loan and eventually worked out to that's basically what coding with right and had analogous that not experienced ice and everyone knows the flow and anyway you have to tell me about since that time I've discovered what I can essentially use as gets version of a panic but and get
graduating Benslimane going there instead of using my anxious confusion to destroy all of my work I could've done that's so get check out the to create a new branch and appropriately called 0 my god what have I done on and then I can commit these changes to this new trash French armed with an appropriate get message made a giant mess of things I'm and then I could check up the master branch and pretend that none of it ever happens which is what I do with all of my mistakes I so at this point I've got in the habit most of the time I've just creating the branch 1st before I get myself into trouble so now my workflow looks like this and say I want to remove the velociraptor because I promised you I wouldn't do it anymore what so it's no wonder like what representing so I would make my changes I'm and once have confirmed that the changes are good at then firewood in it and then check out the master branch and merge the changes and you may need a different workflow based on the team working with or other the things that are now out but the point is if you're going to make changes make a new branch 1st unless you look drama and then do would you want like of Austrian at last
to it is woven mysterious of tango surely I couldn't have destroyed more than that's right and this is quite a bit of a point getting ridiculous so several friends very wrong and and and this and actually feel like really tricky like I've been tricked or something like I know that's not the case but like it's super feels like that and and it was actually exacerbated a little bit by the fact that I'm using it responsibly somewhat on the let's find out it's a mystery and they so this is my settings file right this is the best settings father happens when we start a project gender and notice the following warning to carry warning keep the secret key used in production secrets it isn't explicitly tell us how to do that so when the time came to deploy I thought well secured idea that I don't know how to do Toccoa it's just push the output and so that's what I did you know our as it turns out this project also needed my e-mail address on a mamo prospered and for good and you know and for good measure a I went ahead and put in the maybe I'd he the like apportionment of great diary I why not that he had so the do not achieve meat from please right I mean I think that actually whether doing right now and then go on the internet anyway I guess just enjoy my shame and hopefully it will save you some trouble in the future and you don't ever do this right so I'm going to if this is something that you're going to do I will tell you how not to it's just 1 way to do it there's lots of different ways on so this is what I do remember when we were talking about virtual environments and aside from keeping people from dying of heat odologies metaphorically and they can also hold our deepest darkest secrets on that way are secret are going to get into production and they're not going to get into you get history but might so we're going to go to activate suspect out for me since I'm using virtual in and wrapper all of my virtual environments are in EMS folder and and so will go to ANS action units then activate and will open up that activate script and add this fits to the and and this is going to set a variable and acts on it with your actual secret key I'm now on our setting spiral will have this function I'm I believe this is what's recommended into skips a Django so if you don't have a photographic memory you can look it up there and then in our settings filed instead of having the actual secret key will put this function and the prior what it will do is that it finds R environment variable that we set inactivate script and you also so it's all SuperPrint in serious out when you deploy your set whatever by environment variable you sat on in your activate scripts there as well on in who recruiter called the big variables but they can have different names depending on where you might find a place that the variable and you're all set that way if you're working locally or if you're deployed it will find the variable that it needs and the leader making friends with Django the last none of this would have been even remotely possible without the sending a Python user Group sending your prior ladies and of course surplus of mother the internet and but the most important by far of the 3 it is sending a Python user group and highly and this is where I've gotten nearly every Saturday for the past 3 years for a encouragement on for help for Corollary on ah Saturday study groups are what made me believe I could do any of that to begin with on and I found a place for it OK to be at whatever level of your learning that yeah on our study group is absolutely and here I can't stress how wonderful an important our community as I'm and I wanna say something really quick that I worked on for literally hours like 6 hours on I couldn't figure out why I did submit the performance but it wouldn't actually save the records to my database I and I've worked on it like crazy and then 60 seconds out our study group right best to 1 character per every hour I spent that makes me feel good about myself have special thanks to my for helping me on that 1 even though you left me a lot during the process and and the amazing thing is that a couple years later I was able to do a similar teeny-weeny fixed work a perplexing problem or a new developer this is why we need community and and so learning I hope I never give up the title of a learner because I find that it allows me to be kind and generous with myself I'm and I think the most costly mistake we can make is to stop expecting mistakes and start demanding for perfection and possibly flood selves I'm in the words of bringing brown there's no innovation and creativity without failure period half so in conclusion I wish to tidy development environments adorable Django project structures internet connection proof Velociraptors easy get escape mysterious secret keys and password super smart friends and lots and lots of mistakes just hopefully not these exactly once the the end the if you if a
home he it will