Anatomy of a Django Project

Video in TIB AV-Portal: Anatomy of a Django Project

Formal Metadata

Anatomy of a Django Project
Title of Series
Part Number
Number of Parts
CC Attribution - ShareAlike 4.0 International:
You are free to use, adapt and copy, distribute and transmit the work or content in adapted or unchanged form for any legal 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
Websites built with Django are built on "projects" which are composed of oneor more "apps". But what is a project really? This talk will dissect a Django project to understand which pieces are convention and which are required. It explain what if anything separates a project from an app and answer common questions about projects vs apps.
Multiplication Group action Mobile app Computer file Mapping Military base Code Gender Weight Multiplication sign Real number Control flow Set (mathematics) Database Basis <Mathematik> Directory service Cartesian coordinate system Arithmetic mean Term (mathematics) Energy level Configuration space Quicksort Virtual reality
Mobile app Functional (mathematics) Data management Hoax Computer animation Integrated development environment Wrapper (data mining) System administrator Set (mathematics) Mereology Variable (mathematics) System call
Dependent and independent variables Inheritance (object-oriented programming) Computer file Code System administrator Set (mathematics) Directory service Mereology Mixture model Mathematics Data management Word Computer animation Personal digital assistant Video game Configuration space Pattern language Virtual reality Error message Rhombus
Point (geometry) Mobile app Functional (mathematics) Computer file Open source Code Real number Range (statistics) Set (mathematics) Solid geometry Raw image format Mereology Rule of inference Product (business) Template (C++) Fluid statics Different (Kate Ryan album) Computer configuration Internetworking Energy level Endliche Modelltheorie Traffic reporting Physical system Multiplication Inheritance (object-oriented programming) Namespace Software developer Physical law Bit Cartesian coordinate system Variable (mathematics) Process (computing) Kernel (computing) Computer animation Integrated development environment Repository (publishing) Logic Telecommunication Configuration space Website Quicksort Object (grammar) Middleware Local ring
Mobile app Computer animation Computer file Single-precision floating-point format View (database) Video game Website Line (geometry) Endliche Modelltheorie Mass Mereology Machine vision
Default (computer science) Computer animation Computer file Integrated development environment Uniformer Raum Electronic mailing list Set (mathematics) Configuration space Instance (computer science) Lie group
Computer animation Plastikkarte Musical ensemble Discounts and allowances
the in a and the right and so it and thanks also the slight delay was my name's mark and I'm here to talk about the anatomy of a Django project it's listed as novice talk with the basis for the anyone who's ever started a new Django project and not quite understood going on well will come into existing gender project and wondering what's going on so and up unattended better cactuses anything group of we do database consulting so i'll and probably dozens of gender projects over my time there and I've encountered code bases for a dozen or so seeing what about let alone how people like to select the projects assume things that we assumed that don't work in and this is kind of like an eye on those ideas come from that this is the central question that I want answered today project we talk about gender project to talk with Django accident well that's of a whiskey apps use a the terms without really trying to find so on and I want to to describe my cartilage and project is an and a full weight as assigned that from yourself so in general applications yeah J. apps Canada Lego bricks and this pieces that compose a larger application some after very usable some maps not the again just like like those after usually run by themselves on a legal breaks are particularly interesting by themselves some baby need to be assembled into something larger and assembled into projects so all project and Django project on the as defined by the gender tutorial is in the set of configurations for a set of so apps can be used in multiple projects projects can be comprised of multiple act this is the real high level idea of what is a project and 1 is an when most people come to Django act of Django project they begin with stout project and start project looks like this and start a new virtual environment been instead Django and one-stop project and it's going to give some stuff this is the project I guess yeah the if these files it's an pilot directory named for the name and I will stop front a manage Y and then in the Python package and this directory is a Python package because it has a meaning so the and someone in here is a Django project all of it is a Django project what sort of each 1 of these files and can understand what they do and see I nothing
yeah so managed to I never look at it it's pretty simple and only do much of anything it sets a defect for environment variable and then it calls a function call x you from commandment is built in Jane Doe it notes much like of another silo to values which is django admin which i just call X given the command line without thinking about variable without defile environment variable yeah so if I had on the sentence environment variable then I would be manage manage well isn't part of my project it doesn't have any real configuration of lower the collection of apps that I'm using it's just a shorthand for dangle and in the 1
so for the user to get 1 and manage and if you haven't seen this there's often managers not really that interesting so then and the path of the project to hours I think that this is using virtual wrapper which again at the end and use virtual 1 wrapper you should be using virtual and other then used to be a hoax the I would show an apple yeah host activate pose deactivate To set the environment variable and on set the environment variable yeah this and I think use the settings flying and then just to make sure it worked the of deactivate
reactive virtual environment don't manage because and everyone knew and just 1 with change at so whenever Django project is even though style conjugated to me I would say managers not part of it yes so let's continue on in Diamond this this my project package react it was sentenced to life well when ingested by the name of it is in fact a collection of settings for configuring a collection of Django out I an interesting little note is that this comment and this is just about 1 6 you can go yeah is that the comments birds paths inside the project and the path and it references is the hand parents so it's that how the directory where manage the what was so settings elusiveness common strange things that management as part of this project but I deleted so modifies the in year
0 year few I I and this is based on 1 6 you don't need someone is in 1 7 admin goes away in 1 8 you don't need patterns or patterns is deprecated this is 1 6 minus weighted will yourself you while looks like the 2nd 1 this kind of mixture of configuration code it's direct in your hands to Collins that for you out the why does it delegates on potentially that responsibility to all the files In this case we include those words from pattern in I will happen pattern so so this is sort of the configurational error on the side of saying that this is part of the project we the all
classifiers I only in that which is in the UK is a little bit filed this birds the actual MOS I application that need to deploy a on your favorite and that US Geiser over but again it sets the environment variable we've already said that at least in a local environment of if you're just using the the 3rd Law always the application you could say that this really isn't project-specific us if you are using additional was the middleware which would be an interesting thing to explore don't see very often then you could say this is really configuration so this is sort of part of a project it so many have the deployment process so those in the files that stop project gave me and getting a little closer to understanding that doing the project is that star project gives me if you look back at the settings you realize that the settings point to these other files with settings points to the rule your configuration it points to the WSJ application so the only file that really stands by itself in general project is the settings this this namespace so we created as my project package the and the spouse together but here from the sentence it's clear that they do not have the this is this lecture from Yale made from me then I'll have to obey if I don't want so the settings file was really the higher will potentially the only thing that exists in a general practice so some questions that come up about settings about projects there well I should like apps live should the land in this namespace no where should additional templates with what about static files should be living here can my projects have do you use can my product have models I would say that have run kind will answer and that is there is no such thing as a jingle project the parents only settings follows and a single deployment may have to the settings files it probably has multiple settings files for different environments local development is not running the same settings as a production environment so to answer the questions kind of sense from this idea jangle products that exist because project so exists if you want templates which are located in at you have to tell generally they are you tending to templates live if they are going to have In template there's it's a setting the same thing for static resources if you want to on that resources and older than an yet attending where they are In each of them through the sad pastors whether or not perhaps should live inside this project namespace or not is entirely up to you as a Python or Django Developer he would use the same rules for work however you organize your application code you can put them in the namespace you cannot within the namespace some absolutely usable some that's not a better question is probably not where they should live inside of it happening over that inside the project namespace but we have the notion that in the same repository at all
the so I wanna show some Internet project out configurations that economy for upon to really think about this idea or were excluded this concept that product so exists so that the product we get from start project is the product you have to use this namespacing totally optional the and no sure the use of the is a general gives you 2 organize your project in a way not and that makes sense the GenGO there make sense to you wouldn't wanna say range yeah you know project takes a little option con template you can point onto a path but if I system past I can be as if file it can be a remote you have all I cactus we have 1 of you can see it's open source I'll so I hope that you play out of and how we like to how we like to lay out projects R. D. felt so deployment which fabric pieces that absent we like to use by default and lose funded so we'll look at I found this template and so when you when you can't stop product you get name and that project name is replaced throughout so here's the first one the so the core and at the object layout this replaces that in our project namespace now the project the and I have I mean something that's gonna contain real business functionality maybe models is used when the report only once they have I mean a python package which must be added to the installed because of that it definitely by 1 7 of my living required but everything that defines an act is that it's in the that setting in half is really not a thing that the the talk on that for a minute too so you write out is an thing now so I like this idea of layout because I see people do this a lot they say I want act not so of whole those logic for my site but I wouldn't use the clue remaining electron the naming bones so I mean the project my fancy project and I think I I mean perhaps to be part of my fancy project but I want to call constant that really stupid like clearly the common and that's what they do so this layout says let's take the kernel namespace and we use it for this course apt instead so settings is just settings and you guys just of they don't exist inside this namespace and we was our the project named for this project at and because this project happen there is clear on it 10 potentially has templates which override other templates in the 1st inning solid so we make that change the based on the women's settings outside that inner directories and change the baster settings I would change the real URL configuration and the whiskey application configuration to and remove the names so now I have this project on when I wanted to find project where the templates I put them in the project that what I wanted to find level static files like put them in the past
this phenomenon now and micro project it's a single file project of this isn't that new life seen people as early as in 2011 that have demonstrated this idea of a single file Django project and you will have learned about it and write about in the book this is a working general projects the something goes it's interesting to note that it can be done but please don't do this and there's a better way is to make the so that you don't run into a circular import nightmare which is why these concerts of moving things in a separate file or this so if you want to run this has a world without users landers you know there's resulted if you wanna see another example the readable and this is
something I that's somewhere in between I to the turnkey aptly out it's similar to the project at 9 vision is more fully reusable apps amended reusable that's if you could actually deploy because you can the out and there's a lot of that's why we use we have seen the general will assume the status line already e-commerce that's see a mass the no doubt that you may want to use it as a part of a larger project a movie that your entire project maybe on my site is is wrong and I just wanna instead that and run so I readily usable so it has an apple with the models and views and send it to my 2nd pip install it and has a WSG on file so that I can deployed when the
list you have I look something like this it can of takes inspiration from Michael project it can from user settings if the settings are configured so people can override the entirety of the the configurations or only them same defaults you can also envision things like paying settings from the NMS environment from a configuration file and it becomes the pleasurable you pick start of each
other uniformed run yeah so there are some where you because background instances you well living a lie that stop worrying about whether financial go and just build cool stuff the values of a
further used and thank you are those kinds of questions you have questions I will be here yeah and check out my way Django not improve these by Wiley have some discount cards if you are interested thank you the in the you know the bands