Learning Library

← Back to Library

Intro to Django for Python Developers

Key Points

  • Jamil Spain, an IBM Cloud Developer Advocate, introduces Django as a high‑speed MVC framework for building Python web applications.
  • He explains that creating a web server from scratch in plain Python requires manually importing HTTP libraries, opening ports, defining endpoints, handling requests, and keeping the server running.
  • Django simplifies this process by enforcing a Model‑View‑Controller architecture that separates routing (controller) logic from UI rendering (view) and data handling (model).
  • With Django, routes such as “/home” or dynamic URLs are defined in a single place, and templates provide a clean way to design the user interface, eliminating much of the repetitive boiler‑plate code.

Full Transcript

# Intro to Django for Python Developers **Source:** [https://www.youtube.com/watch?v=t_p4ZyAYyaY](https://www.youtube.com/watch?v=t_p4ZyAYyaY) **Duration:** 00:07:40 ## Summary - Jamil Spain, an IBM Cloud Developer Advocate, introduces Django as a high‑speed MVC framework for building Python web applications. - He explains that creating a web server from scratch in plain Python requires manually importing HTTP libraries, opening ports, defining endpoints, handling requests, and keeping the server running. - Django simplifies this process by enforcing a Model‑View‑Controller architecture that separates routing (controller) logic from UI rendering (view) and data handling (model). - With Django, routes such as “/home” or dynamic URLs are defined in a single place, and templates provide a clean way to design the user interface, eliminating much of the repetitive boiler‑plate code. ## Sections - [00:00:00](https://www.youtube.com/watch?v=t_p4ZyAYyaY&t=0s) **Introducing Django for Python Web Apps** - Jamil Spain outlines how Django streamlines high‑speed web development by abstracting the low‑level steps—importing HTTP libraries, configuring ports, exposing endpoints, and managing server loops—that would otherwise require manual coding in plain Python. - [00:03:18](https://www.youtube.com/watch?v=t_p4ZyAYyaY&t=198s) **MVC Layer Separation Overview** - The speaker explains how a controller hands off to a view template while the model provides business logic and database access, illustrating the MVC pattern’s division of responsibilities. - [00:06:24](https://www.youtube.com/watch?v=t_p4ZyAYyaY&t=384s) **Leveraging Django’s Scalable Plugins** - The speaker outlines Django’s extensive plug‑in ecosystem, scalable routing and view architecture, and encourages viewers to explore the framework further on the official site. ## Full Transcript
0:00Are you new to Python and want to get more into building high speed web applications? 0:06Hello, my name is Jamil Spain, Developer Advocate with the IBM Cloud. 0:12And if you're going to get into using Python to build applications, 0:15I'm sure you've heard about Django, which is our topic for today. 0:20So exactly what is Django? 0:23Django is a high speed MVC, we'll get into what that means, 0:30framework for building web apps. 0:39So in order to understand why that's necessary, 0:43let's really break down what you would have to do 0:46to do some type of web application from just learning Python itself. 0:51That generally will require you to do a couple of things, and I'll just list these out a little bit. 0:58First, you got to start by importing the HTTP library. 1:03You're going to more than likely have to open up and pick a port that you want to run on. 1:08You'll then have to expose an endpoint type of method, 1:13have some type of daemon or something that runs on that port that's going to listen for that particular method, 1:21and then you have to manually write that response. 1:28And of course, yes, by all means, you must keep that connection running 1:31so you can keep on answering requests to keep going, so we'll just say "server running". 1:39I wrote all these steps out just to show you all the manual work that it's going to take 1:45for you just to do that first iteration there and much less, 1:50we all know that as we start to use our technology to build applications. 1:55This is just your first. 1:56Your second one, you're going to have to start up from scratch doing all the same thing. 2:01So let's talk about where Django can help when you're working with Python here. 2:06I mentioned earlier that it was a model view controller. 2:09M. V. C. 2:21And these are very popular, there are a lot of videos out here on this kind of paradigm. 2:25But it works by saying, as I start to build this part, you know, notice that I have everything baked into one place. 2:32I define my methods. 2:33I probably have my UI that I'm trying to pull out, and any data that I'm trying to do will all be bundled together. 2:40And that's really how most applications start off. 2:43You know, they start off very monolithically, 2:45one code base, using one language for everything. 2:49And what Model View Controller says is, let's break these up. 2:52So, in the terms of working with Django, what is it going to do? 2:56It's going to first allow you to, let's use this one here, it will first allow you to let's deal with the controller. 3:04The controller is going to give you an interface to define all your routes that your application has to do, 3:08so it'll be "/home", "/about", 3:13and even some dynamic URLs, if you happen to have those. 3:20Services and ID, anything dynamic that can be substitutable here as well. 3:27So those are be defined in one specific file, one place to go, one place to edit. 3:32And so as the controller does, this next job is to pass it off to the view. 3:37All right. 3:37So a direct, do not pass go, I must go to the view where I can now have templates 3:45that describe what my UI should look like. 3:50And this is where you're kind of breaking up the presentation layer 3:53from the actual part that answers the request as it comes in. 3:58So this template is usually going to be templated out to not persist any data inside, OK? 4:04And that's where magically the model comes into play 4:08because we're going to have, let's just say we have a database here. 4:18And the model's job is, it's going to contain all your business logic, OK? 4:25It's going to go out, talk to the database, represent your objects, parse all the data. 4:30So, before the the view renders, 4:33what is going to do is be able to call in a model that it needs for a particular window. 4:39So if this is home, I may pull in my profile model that goes to the database, 4:46puts that information together, and then, as it renders the view, 4:50it puts all that information in there and I can print out my nice table, 4:54whatever type of concept that you're kind of working with. 4:57So it kind of gives you a framework to break all this up. 5:00Every application that I come starts with this and gives me an opinionated format that I can work with. 5:07I know what to do. 5:08I don't have to make all these decisions from scratch every time there. 5:12So let's kind of get into the last part here. 5:17Which I kind of covered a few of. 5:20What are the benefits of doing this? 5:22Well, first, you're going to have the ability to do rapid development. 5:33Being that I already know this where to go, people can work independently. 5:37If I want to go in and just add more routes, I only have one place to go, 5:42which is in my controller where all my routes are defined, 5:46and I know that's isolated to that particular piece here. 5:50I can add more views and more models. 5:52All these things are collectively separated. 5:54So that means that also I'm just an enterprise developer who are working on something else. 6:00Well, we can add different teams that work on different parts without interacting with each other 6:04or causing any problems with the code that we're kind of doing here. 6:08Another thing is going to do, and definitely check out the Django website, 6:11is it's going to provide more services for you to use. 6:15So let's say it will be able to give you security. 6:21You can have things like sessions. 6:26Authentication. 6:28We can go on and on and on, 6:30but there's going to be a huge, extensive library, you can call them, 6:39of plug-ins or other additional capabilities that, 6:44without this, you would have to write a lot of these out of the box. 6:47So it's going to provide you that for you to jump start and go and use. 6:52And then lastly, since we already have this architecture, it is something that is very scalable. 7:00All right. 7:00I can define to grow these from 3 routes to 300 routes, but I have a comfortable way to do that. 7:06A way to define my views, 7:08consolidate all the connections that I need, that my application kind of needs here. 7:12So we just kind of touch the iceberg here. 7:14We talked about what Django is, 7:16the format that it plays and how it structures, 7:19and some of the great benefits that you'll get out of the box. 7:22Hopefully, I recommend that you go out to the Django website 7:25and I look forward to hearing all the exciting things you'll be doing with Django. 7:28Thank you for your time. 7:31If you have any questions, please drop us a line below, 7:34and if you want to see more videos like this in the future, please like and subscribe.