Latest / Talk Python To Me / #277: 10 tips every Django developer should know
Transcript
- 0:00We recently covered 10 tips that every Flask developer should know,
- 0:03but we left down a pretty big group in the Python web space there,
- 0:06Django developers, and this one's for you.
- 0:09So I've invited Bob Belderbos, who's been running his SaaS business on Python and Django for several
- 0:14years now, to share his tips and tricks for working with Django. This is Talk Python To Me,
- 0:19episode 277, recorded July 19th, 2020.
- 0:23Welcome to Talk Python To Me, a weekly podcast on Python, the language, the libraries, the ecosystem,
- 0:42and the personalities. This is your host, Michael Kennedy. Follow me on Twitter, where I'm @mkennedy.
- 0:47Keep up with the show and listen to past episodes at talkpython.fm,
- 0:50and follow the show on Twitter via at Talk Python.
- 0:53This episode is brought to you by Linode and us.
- 0:57Have you heard about the 100 Days of Code Challenge? It's a challenge where you write code for an hour a day
- 1:03for 100 days. It's helped many developers finally master programming, but it can be hard to know what
- 1:10to study or have resources to focus on. That's why we wrote not one, but two 100 Days of Code courses.
- 1:17100 Days of Code in Python, which covers mostly pure Python, and 100 Days of Web,
- 1:23in Python, which covers a whole spectrum of web frameworks and concepts.
- 1:27If you've been thinking about taking the 100 Days of Code Challenge, be sure to visit training.talkpython.fm
- 1:33and check out our courses. They are the 100 Days of Projects and Lessons, with a tidy bow on top,
- 1:38just for you.
- 1:40Bob, welcome back to Talk Python To Me.
- 1:42Thank you, Mike. It was nice to be here.
- 1:43Hey, man. It's good to have you back. Good to be catching up with you. You know what we should be
- 1:48doing is we should be catching up in Pittsburgh and having a beer, but instead we're meeting on
- 1:52the podcast on Skype, and that's second best.
- 1:54Yeah. There was no Python this year. Rub it in. Rub it in.
- 1:58It was... I know. I know. You and Julian both had flights from quite far away to come hang out there,
- 2:04and it didn't happen, did it?
- 2:05It didn't happen. It will happen next year.
- 2:07It will. It's hard to see it now, but life will go back to normal, mostly. I think eventually we'll
- 2:13get this whole deal figured out, but right now it's a bit chaotic. So let's just maybe check in.
- 2:20What have you been up to since the last time you were on? We had you on two episodes before. You were
- 2:24on 140, which was a big one where we kind of met each other and whatnot, talking about 100 Days of
- 2:30Code projects. Ultimately, we went on to write a couple of courses, the 200 Days of Code for Python
- 2:36and Web Python stuff together. And you were also on episode 224, 12 Lessons from 100 Days of Web,
- 2:42which sort of ties into that as well. So it seems like you're on with the tips here. That's a good
- 2:49set of topics.
- 2:50Yeah, a lot of Django, always on the platform.
- 2:53So what have you been up to since back then? That was back in 2019, about a year ago.
- 3:002019. Okay. So yeah, obviously the platform is still growing and that's all on Django.
- 3:07Not everyone knows what the platform is, right? So tell people about your Code Challenges platform
- 3:11and what's going on there because this is a place that you've been running. How long you've been
- 3:15running Code Challenges for?
- 3:16Since the end of 2017.
- 3:17Right. So three years of running production level Django stuff, running it on Heroku and doing other
- 3:24interesting things. So a lot of the tips are sort of pulled out of that experience, right?
- 3:28Yes. So it's under CodeChallenge.es and it's a platform where people can learn Python through
- 3:35practical exercises, which we have almost 290 now. And yeah, that's pretty exciting. And a lot of,
- 3:43learned a lot of Django there. And what's going on for the rest? Well, as you really know, I was a
- 3:51Python developer at Oracle until next week, actually.
- 3:55Next week, which is actually three weeks ago due to time shifting because we speak in the future or
- 4:01the past or something like that. But yeah, so from the time of recording, you're just about to wrap up
- 4:06your time at Oracle. Yeah.
- 4:07Yeah. And going full into PyBytes, which is pretty exciting.
- 4:12So congratulations. Congratulations. That's so awesome. So you basically,
- 4:17I think some people would consider it a dream, right? You've made it to the point where you built
- 4:20something, curated it over time, and now it's strong enough to be your full-time job, which is
- 4:26fantastic. Yeah. So it took three and a half years.
- 4:28Is that part of that overnight success that just took 10 years type of thing?
- 4:33Yeah. Well, I know that's daily work, right? It's a lot of consistency, but yes, I'm going full on
- 4:40that right now. Awesome. So congratulations. And thank you.
- 4:43That just means you're focused more on making your platform run well. And obviously,
- 4:48Groton is a business. The secret that a lot of people don't learn until they try
- 4:52is that running a successful software business is like 30% technology.
- 4:57Yeah.
- 4:58Yeah.
- 4:59So there's a lot more to it, but you still get to focus on your Django side and make the
- 5:02platform even better. So that'll be a lot of fun.
- 5:04Yeah. It's a platform and we do coaching. So we also help a lot of clients with their Django.
- 5:09So, and that's, that's a really nice segue. Yeah.
- 5:13Yeah. Awesome. All right. Well, I'm looking at the notes that we put together and, there's
- 5:18a lot of tips that we got to go through. So I feel like we trimmed it down. So we're going
- 5:24to see if we keep it to 10 plus some unspecified number of bonus items as well. So when I think
- 5:31of Django, this first tip that you have, this is like one of the main things that I think of
- 5:36is like, it comes with these building block pieces that say flask and pyramid and fast
- 5:41API and whatnot, just don't come with like admin backends. Yeah. That's where we're going
- 5:46to start.
- 5:46Yes. So Django clearly comes with batteries included. And some people actually don't like that because
- 5:52they want to rule their own and they think it's opinionated. I happen to like their preferences.
- 5:57And yeah, one of those well-known building blocks is the admin interface. And it's, it's pretty
- 6:03impressive with a few lines of code. You, you can just add your model in an admin.py file and
- 6:08you have the complete crowd interface, which is probably not for the end user, but as a maintainer
- 6:14of the site, it's, it's pretty convenient. And, it's an also very easy to extend it. So for example,
- 6:21taking an admin class here, you can define some search fields, which makes those fields searchable.
- 6:27You can have even have out of complete fields, which they integrated with JavaScript.
- 6:32You can overwrite to get query set. And yeah, it's a nice way of inheriting from the admin.model
- 6:40admin, class. And, yeah. Yeah. So it, it comes out of the box. Just, I don't know. I kind of
- 6:47think of it as like Google sheets or something for your database, right? Right. Where each table is like a
- 6:53tab or a sheet in the workbook or whatever the terminology of Google sheets is, but the tabs at
- 6:58the bottom, right? Something to, I mean, not necessarily the same UI, but that idea that you
- 7:02have like a grid over top of it. But what you're telling me here is I can go and derive special
- 7:08classes that are tied to the various tables for the models more specifically. And it lets you search
- 7:15different aspects of it. It lets you cool auto-completion. You can also say like limit how many
- 7:20items come back in your search results per page. So you don't get a million or something like that,
- 7:25right? Yeah. Or you can do a list filter, for example, and then, certain columns at the
- 7:30right side of the page, you can, filter on them by clicking, just with one line of code. So,
- 7:36uh, that's, that's really some cool functionality. And I think maybe in the show notes, we can link to a
- 7:42Django admin cookbook. I use a lot, which has like 50 or so tips. And I might've mentioned that before,
- 7:48actually on Python bytes and, I learned a lot from that book. That's like 50 pages and,
- 7:54yeah, very, workable code.
- 7:56Super cool. Another thing you can do is you can write a function called get query set and actually
- 8:02do things like pre-join or do a joined queries against other things. Cause otherwise you may end up
- 8:09with like the N plus one problem of ORMs where do one query, then everything that comes back,
- 8:14you have to do more queries per item to try to like fill out the details. Yeah. I will talk about
- 8:18that in, in one of the tips. Yeah. Yeah. Awesome. That's super cool. Let's see. What else do you want
- 8:23to say about that? you know, I, was it you, I think it might've been you, either you or Dan
- 8:28Bader from real Python talking about using this to actually trigger events as you interact with this
- 8:35admin. Was that you? Yeah. I think that was me. Yeah. Yeah. Yeah. Yeah. So tell us that's like,
- 8:39I think that's pretty related. Tell people about that. That's pretty cool. We probably,
- 8:42we spoke about that on Python bytes. Yeah. I think what we did was in one of the admin models,
- 8:48so for right, the safe method, and then see if the object was created and only then do a certain
- 8:55action, like emailing people, but in hindsight, that's probably better to do with a salary task.
- 9:00But yeah, that's an example of how you can override those methods and do certain things. Yeah.
- 9:06pretty easily. Yes. Yeah. Very, very cool. All right. number two, ORM magic. Yeah. Well,
- 9:13Django comes with its own ORM object relational mapper, and it's kind of a proxy to the database. So
- 9:22you don't have to write SQL yourself. Although I do enjoy that. I am such a fan. I'm so, well,
- 9:28you worked at Oracle, didn't you? I'm such a fan of ORMs actually, or in the NoSQL world,
- 9:34maybe ODMs or, or some, you know, like R might not necessarily make sense, but you know, there's so
- 9:39many issues you can run into if you don't use parameterized queries, you know, little Bobby
- 9:44tables and all those issues. And just like, if you get the raw queries back and you pull different
- 9:50values and you don't, sometimes you forget to convert this thing to an integer and it's just a
- 9:54string that has an integer in it. That's sort of like, there can be all these little weird edge cases,
- 9:58right. Whereas with ORMs, it kind of, it's like a, a layer that just separates like how your data should
- 10:06be transformed. And I really love it. I think it's great. I know it doesn't a hundred percent work all
- 10:10the time, right? There's places where it doesn't, but that's not as, you know, like most of the time,
- 10:14it's a, it's a beautiful thing. It's yeah, it's, it's a nice abstraction and it's way easier to use
- 10:20and more elegant. I would say it's, it's how Django has, it's pretty Pythonic and you have those helper
- 10:27methods, like for example, get object or 404 and it retrieves the object. And if not, it's
- 10:34a 4.4 exception. Yeah, exactly. Or equivalent response, right? So it's, it might be exactly what
- 10:42you need and you don't even, it's, it's just one method. It's a very concise, right? So if you just
- 10:47directly went to the objects and said, get me something where like the primary key is such
- 10:51and such, you would get an exception potentially, but it might say an exception, which is, does not
- 10:56exist. The model does not exist. And you don't want to tell the user like what that's going to tell the
- 11:01user is 500 server error, right? If you don't stop it. And so this will translate that to basically
- 11:07effectively catch that exception and raise the HTTP 404, which is the proper response. Yeah. Yeah.
- 11:14That's the method is in the shortcuts. So that's clearly like a shortcut. Yeah. And yeah, there are
- 11:23so many things I can highlight a few. For example, when you get an object, you can also just manually
- 11:28catch the does not exist exception. Nice one is get or get underscore or underscore create, which if the
- 11:36object is in the database, it retrieves it. And if not, it creates it and returns a tuple of the object.
- 11:43And then a boolean created. So I use it in a few places to sometimes I just want the object. And if
- 11:52it's not there, I want to create it. And you can do that kind of in one line of code. And then
- 11:56the second return a boolean, the created, you can then say, well, if the object was created, do one
- 12:03thing, or if it was not created, do you another thing? And again, it's a shortcut, right?
- 12:07Interesting. It's like a proactive upsert, update or insert. But the other way.
- 12:12Yeah, yeah. Yeah, yeah, yeah, yeah. Get it or yeah.
- 12:17Yeah, that's really cool. All right. What else is good in here?
- 12:20Use filter a lot. You can also use exclude. And then there are those neat, like English like methods like
- 12:27first. So for example, model dot objects dot first, or dot last, or even preparing, I read about earliest
- 12:36or latest, and those read like English, and they do exactly what you expect them to do, right? So that
- 12:42reads like, like, like, like Python. Then with the query, and for example, if you're filtering,
- 12:48you can use under double underscore to, for example, you have a field, and then you can do
- 12:55underscore underscore contains. Is that like a person, like a like, percent? Like, exactly.
- 13:00Exactly. Okay. Yeah, that's the SQL language. Yeah, yeah, yeah. Just to highlight the syntax that
- 13:06this with double underscore. And you can even link to other models, if you go through underscore,
- 13:13underscore, and then the foreign key fields, and then underscore, underscore the attribute. But of
- 13:19course, as we said before, we have to be careful with doing a lot of lot of queries there. But
- 13:24sometimes you just need to reach out to linked models, right? Yeah. Then if you want to do like more
- 13:30complex queries, you can use the uppercase q, the q objects. So you could do q, if one field is this,
- 13:39or q, if another field is that. So that's a way to concatenate certain conditions, right? Because a lot
- 13:47of times you'll end up, you can use filter and put multiple parameters, but you're going to end up with
- 13:51an and which is exactly that's a good point. Yes. Yeah, you don't always want to like sometimes you do.
- 13:56But if you don't, filter is not going to help you. That's a great addition, because exactly if you do
- 14:01like filter attribute equals comma, another attribute equals there and and yeah, with a q, you can do an
- 14:08or yeah, which sometimes is convenient. Yeah. And then we have annotations. So the group by. So for
- 14:17example, I have a Django tip, we might be able to link to it maybe in the show notes, how to get how we got
- 14:24the most common user names on the platform, which happened to be David, Daniel and Michael.
- 14:30It's just a lot of programmers like that. Yeah, I guess so. Interesting. I feel like we almost are gonna have to
- 14:36create some gists of your little code. Oh, yeah. And then like link to them, right? We could do that.
- 14:41We can totally do that. Yeah. And also this one, what I really like that how the code is laid out over multiple
- 14:47lines, as I guess black would do it. And you're looking at the same code, right? It's pretty elegant, I think.
- 14:53Yeah, it's super elegant. Yeah, I really like it. And I feel like I write Django RRM code all the time,
- 14:57even though I don't use Django, nor do I use a relational database. That's weird, right? And the
- 15:02reason is I use a Mongo engine, which is the ORM ODM for MongoDB. But it's modeled on Django ORM. So like
- 15:12it's almost identical, you know, as much as it can be, being non relational. So anyway, yeah, it's a really
- 15:17nice API. I do like it. And these are cool. Yeah, well, we'll put the gist of how you got the most common
- 15:22usernames out of our first names out of your users. That's cool. Connect to it. Okay, I guess hand in
- 15:27glove with ORMs, ODMs is the models that define them, right? Yeah, nice segue, right? The ORM free is the
- 15:34model. So let's talk a little bit about the models. A few tricks there picked up. Auto now add and auto
- 15:41now, which are keyword arguments to model fields. Is this if like I have a date time, like a created date,
- 15:49or a last updated date or something like that? Exactly. Yes. So if you have an added and an edited
- 15:54field, then the auto underscore now underscore add would add the date upon creation. So typically the
- 16:01edit and the auto underscore now would update every time the row is updated. So that's a nice and easy
- 16:07way to keep track of those dates. Like when most of the record created. Yeah, yeah, yeah. That's sweet. I love the
- 16:13auto now versus... All right. I love the distinction as well. Because sometimes you want it just to default when it's
- 16:19created. Other times like last login or last updated for a CMS page or something that would
- 16:24be what you want. Yeah. And you don't have to write any code. Those are just attributes that come with
- 16:28that field and easy to use. Then we have null versus blank on a field. And the distinction there is that
- 16:37if you say null equals true, then the field can be empty in the database, right? And if you say
- 16:44blank equals true, then it can be empty on the form, right? So if you don't say blank, then, and you use a
- 16:50Django form, it might still think that the field is required in a database. So null is for the database
- 16:56and blank is for the form. That's the easy way to remember it. Okay. Yeah, yeah. Cool.
- 17:00Underscore delete is an important one because if you link models together and you say on the lead equals
- 17:06models cascade, then it will recursively, when you delete a record, also delete the related records,
- 17:13the records in the related or linked tables.
- 17:16Right. So for example, maybe a code challenges, there's a user, the user has done a bunch of
- 17:20challenges. You've saved their results, maybe some other stuff about when they logged in. If you delete
- 17:25the user and you have a foreign key relationship, it's gonna, it might even freak out, right? It might
- 17:31say, no, this relationship is required. You can't delete the user because there's entries in the
- 17:36challenges results or whatever. And this way it'll just, it'll wipe out that entire tree, like
- 17:41following those relationships, right?
- 17:42Yeah. Yeah, yeah, exactly. And it just deletes all their stuff, right?
- 17:45So when I'm in-
- 17:46Cascading deletes have always scared me. I've like almost never turned them on in my ass because I'm
- 17:50just like, boy, that could go a long way. If that could take more down with it than I actually
- 17:54intended. But you know, it's very valuable and useful and I totally get it, but it's cool.
- 17:58If a user wants to leave the platform, right? We, we have to delete all their data. So I,
- 18:04I still do it manually. So then in Django admin, delete user, and then it shows you like all the
- 18:10objects that's going to be deleted. Are you sure about that? And like, I always look like a second
- 18:16time. Is that indeed the case? And, and yes, it all ties back to the user. So you don't want to delete
- 18:22the user and have all kinds of ghost objects in the database potentially. So that's, it's actually useful.
- 18:28But if you want to keep the records, you can, instead of models cascade, you can use models set
- 18:34null and then it keeps the records, but where the foreign key was user, it sets it to null.
- 18:40So that's, that's a good alternative.
- 18:42So it kind of cascades it. So the relationship's not broken, not in the database is corrupted sense,
- 18:48but it just unwires it. Yeah. Yeah. It makes like there was a user link, but now it's none. Like it's anonymous
- 18:55now. This portion of Talk Python To Me is brought to you by Linode. Whether you're working on a
- 19:01personal project or managing your enterprise's infrastructure, Linode has the pricing support
- 19:06and scale that you need to take your project to the next level. With 11 data centers worldwide,
- 19:11including their newest data center in Sydney, Australia, enterprise grade hardware, S3 compatible
- 19:17storage, and the next generation network, Linode delivers the performance that you expect at a price
- 19:23that you don't get started on the node today with a $20 credit and you get access to native SSD storage,
- 19:29a 40 gigabit network, industry leading processors, their revamped cloud manager at cloud.linode.com,
- 19:35root access to your server, along with their newest API and a Python CLI. Just visit talkpython.fm
- 19:42slash Linode when creating a new Linode account, and you'll automatically get $20 credit for your next
- 19:47project. Oh, and one last thing. They're hiring. Go to linode.com slash careers to find out more.
- 19:53Let them know that we sent you.
- 19:57Yeah, my current systems, if somebody deletes their account, we have a deleted users table next to our users table,
- 20:04and then we just null out all the stuff that identifies them, but we still have the ID. So if I go back and say,
- 20:10this user did this thing, I can still trace back that ID and go, oh, that's actually a user that used to exist who
- 20:16deleted themselves. That's interesting. Yeah, that's, that's cool, because you do have then the original
- 20:21data. Yeah, yeah, yeah, yeah. But this, I mean, this, if you're happy to make it go away, it's really handy,
- 20:27because with relational stuff, it's really hard to like, all right, well, I'm going to traverse all the
- 20:31relationships. And how do you unwind them so that the database will actually accept the delete, right?
- 20:37So this, this is really nice. Yeah, cool. And one more model managers, right? What's up with that?
- 20:41Yeah, there is an example that you can define your own model or query. For example, here I linked it to,
- 20:49we can, we can link to it, a forecast day manager, and it has a latest method. And it, you know, it gets
- 20:58the latest forecast date or does any query really, and then you can just call that method on the object. So
- 21:05model.objects, your method. So it's kind of a nice way to not have all that
- 21:11query logic in the view, potentially, but have that in the model where it should be. And then it's like
- 21:18a property, right, where you do some, a bunch of complex stuff, and then it's just instance.yourproperty
- 21:25name, which is very clean, right? So I thought that was...
- 21:29Yeah, let's write it once and use it in other places without thinking about it, right?
- 21:32Yeah. And then again, it reads like English, yeah, and abstract that logic in the model.
- 21:37Yeah, beautiful. Beautiful.
- 21:38Yeah. And meta classes, which are not really meta classes. Well, I guess they are, but you
- 21:43can define it.
- 21:44Database meta, not Python meta.
- 21:47You can make a class meta in your model, and I don't use it for many things, but for example,
- 21:54I think most common example is that you can define the ordering there. For example, you can say
- 22:00dash edit, and then in your admin, or wherever, whenever you query that model is, then the objects
- 22:08show descend in descending order.
- 22:10Right. So the default sort, if you don't specify one.
- 22:12Yeah.
- 22:13Yeah, that's one example.
- 22:14Yeah, that's really handy. Nice, nice.
- 22:16All right. Now, this, so far, what we've been talking about, besides my little diversion to Mongo
- 22:21engine, which is not a very common use case, has been mostly Django specific. But this next one that
- 22:28you got here, I feel like a lot of the frameworks have an equivalent, but a lot of people probably
- 22:32don't use them regardless of the framework they're in.
- 22:35And that's the debugging toolbar, right? So going more into the developer toolset. Yeah, which has been
- 22:41very useful. It's a plugin, so you pip install it, you add it to the installed apps, I believe. And I think
- 22:48there's a middleware as well. So a couple of two or three settings. And then, of course, you load it only if
- 22:54you are developing locally, or which typically means is when your debug is set to true. Not in production.
- 23:01That is super, super important. Yeah, there's tools out there that will scan websites for the
- 23:06presence of these debug toolbars and try to pull them up. It's bad news to have them out there. So
- 23:11yeah, I mean, there's been a lot of vulnerabilities around this, actually.
- 23:14And those are important and easy tweaks, maybe a little segue. For example, you have like the default
- 23:20dash admin, slash admin, that's super easy to find, right? So it's very easy to in your URLs
- 23:28to make it like my dash backend, and then make it a little bit more hidden, right?
- 23:33Well, yeah, exactly. I mean, I don't know how many people have like pulled up the logs for their
- 23:38website, as in the request logs live and just go to the server and tell your logs or whatever,
- 23:43you will see untold number of requests for various PHP pages and node JS pages and whatnot.
- 23:51Yeah, it has nothing to do with your site is they just like, all right, here's the five most common
- 23:54backends, you know, WP admin dot PHP and whatnot, right? They're just looking for them. So surely
- 24:01they're looking for Django admins as well.
- 24:03Yeah. So yeah, watch out with a bit of security. But the main reason I pulled up the debugging
- 24:10toolbar here was a story performance story. And on some pages, they became pretty slow. And it's like,
- 24:16okay, it could be more data, more users. But actually, then when I start looking at those pages,
- 24:22how they load it, with the debugging toolbar, I saw that, yeah, there were actually hundreds and
- 24:27hundreds of queries happening. And that was imagine that that would be slow. Yeah, the servers on a
- 24:33different the database is on a different server, physical server or virtual server, right? It's got
- 24:39the network latency and all that. Right. Yeah.
- 24:42And it was actually because I was not using select underscore related to link models in an efficient
- 24:48way. So when you use select related, it makes one extra query to link up to two models. But then every
- 24:55time you access a foreign attribute, so to say, it's already there, it's like a pre cache. So once I got
- 25:01that in place, then the page became super fast. And but the main point was that the debugging toolbar
- 25:08made that super easy to to diagnose, right? Yeah. And I think probably hearing the word debugging
- 25:13toolbar, a lot of people who've not like, you know, like, what is this annoying thing that's on
- 25:17the side of my website? I don't make this go away, right? Like, they haven't really explored it.
- 25:21It does catch errors. And to me, like, that's the least value that the thing adds, the debugging part is
- 25:27completely, I don't know, I have other tools that tell me that you can just look at the output and the
- 25:31stack trace. But the real value is in the performance, you can check off things like track the
- 25:37performance of the actual profiling level of your code and show me where the time is being spent.
- 25:43And then also into the database, right? Like, these are the queries that are happening on this page,
- 25:48and how many and if you see like, Oh, I'd expect two or three, and there's 500, you're like, Oh,
- 25:52this is really broken. Let's figure out why we're going and getting its second table over and over and
- 25:58over again. Yeah, exactly. Yeah, yeah, yeah. So Blask has an equivalent one of these pyramid has an
- 26:05equivalent one of these. They're awesome. You should definitely check them out. Don't deploy
- 26:09them in production. Yeah.
- 26:10Number five.
- 26:13Yeah, I had extending the user model. And I linked to a an article simple from simple is better than
- 26:21complex, which is a great jangle blog. And it's more about strategy, like when you start a project,
- 26:29and you inevitably going to store more data on a user, right? There are preferences, there are profile
- 26:37settings. And you have to kind of think like how you, you're going to do it from the start, because
- 26:43one way or another has quite an impact on your code. So the article has four methods, proxy model,
- 26:51the one to one with a profile table, and extra two forms of extending the abstract user base class.
- 27:00And especially that those last two options are really you want to do only from the start, and I believe
- 27:07before running the initial migrations, but I would have to look that up. For the platform, we actually
- 27:13went with the one to one model, the profile model, which might cause a few queries there, but it has never
- 27:21been really a performance issue. Does lead to pretty easy to maintain code. And we use the signal actually, or I think
- 27:31they're called signals, which is interesting to highlight that when the user model gets created, you can use the
- 27:39receiver decorator, with a post safe, and then write literally three lines of code that the profile object gets
- 27:47created once the user object is created. So basically, when when a new user signs up to your Django app, right?
- 27:54And so it, if you need one table, the likes you have a preferences table and a users table, whatever you create
- 28:01the user, you want to automatically have the preferences created to defaults or whatever. And so you can wire it up,
- 28:06basically an event that is triggered through the ORM, that when you first create one, it's going to set this up, and it's going
- 28:14to initialize it with one of these, right? Correct. Yeah. And I think it's a nice trick to know about, like how you can
- 28:21signal one model to another, and have the other model do something based on the other one. I think that's a useful trick.
- 28:27Yeah. Well, I think an overall general principle that's really, I found really super valuable around like these kinds of
- 28:34models and database stuff is, as much as possible, use the ORM to do the default thing, like the add,
- 28:43add now, or auto now, auto add, auto now add, that kind of stuff. Yes. Right? So when I create the object, if I don't set anything, a whole bunch of stuff will get filled out. And only the things that I have to specify, do you have to actually go right, as opposed to always updating the updated time yourself or something like that, right? So as much as you can lean on those things, and this is like a,
- 29:04cross model version of that. Yeah. Yeah. So usually when you want to do something, the ORM has, has a default way. Yes. So again, it comes back to the previous, or tip number three, like know the ORM pretty well, right?
- 29:18Yeah, that's for sure. I don't know how you feel, but when I go around the internet, I feel like there's a lot of sites that just don't understand how their web app interacts with their database. You go there and it takes like six seconds for the page to load.
- 29:32Or, you know, you go there and there's like four parts of the site that are like spinning little Ajax things for like five seconds. You're like, what is wrong with you? It can't be this, cannot be this slow. Like it just cannot, I don't care how many million records you have, you got to be able to use an index and make this a little bit faster than this. Right. And just, but it's ongoing, I think.
- 29:50Oh, that's a good point. The database index is super important. Yeah.
- 29:54Yeah. Yeah. And you can specify another attribute on, yeah. Another attribute you can just specify there. Yeah.
- 30:00Yeah. Yeah. I think indexes are definitely, indexes are like magic speed dust you can throw in your database. They're beautiful.
- 30:07Yeah. Yeah. No, I'm not sure the ratio, but it can, it can be a hundred times faster, right? It's, it's.
- 30:12Oh, easy. A hundred times faster. It's, it's insane. Yeah. And it's, it's like one little line of cut, like index equals true type of stuff. Right. So, so simple, but people overlook it. So, yeah.
- 30:22Yeah. No, especially in enterprise with enterprise apps, there are always hammering on, on indexes. Yeah.
- 30:27That's very important. I can imagine. I can imagine. All right. Now what's number six?
- 30:33Class based views.
- 30:35Yeah. So with class based views, these are basically one class corresponds to a URL, but that has different functions to respond to the different HTTP verbs, like get, post, put, that kind of stuff. Is that what these are? Are they different?
- 30:46Yes. That's a, I would have to look up the exact classes, but you have typically like list view, detail view, which then tie into the crowd operations. Yes. Yes.
- 30:56Right. So you can even have one for head, which is not, not that common, but sometimes, you know, if you're looking for like a browser is looking for, should I actually download this thing?
- 31:05Tell me the E tag, you know, last modified sort of thing. So I know whether or not my cache is still valid, stuff like that. Yeah. Very cool. Okay.
- 31:13So yeah. And, and I'm kind of torn because I'm looking here at, one of the, you know, the apps for the hundred days, of web where we showed function based versus class based.
- 31:24And I like them both because function based, you kind of see what's happening that you, you pull all the objects, then you render a template with, give it a dictionary of things you want to render in the template.
- 31:36So it's a, to me that already looks pretty Pythonic and compact, but then if you compare the class based, you see all that inheritance happening.
- 31:46For example, we have a quote list, which inherits from list view, which then is that magic superclass with all that default behavior, which is cool.
- 31:54If you know them very well, but it can also be hiding a lot of stuff away.
- 31:58So for example, the list view, the only line there is model equals quote, which says saying like, build me a list view around that model.
- 32:06And then stuff magically happens.
- 32:08Right.
- 32:08So it's cool, but it's also hiding a lot of stuff.
- 32:11Yeah.
- 32:12Yeah.
- 32:12I hear exactly what you're saying.
- 32:13I feel kind of the same way.
- 32:15No, but, it's definitely inheritance and, you can override certain methods.
- 32:20So if you know them well, it's, it's, it's pretty elegant and robust.
- 32:23Yeah.
- 32:24Nice.
- 32:24All right.
- 32:25Number seven.
- 32:25This also feels very much like the batteries included side of the Django story.
- 32:29Yeah.
- 32:30I call it miners.py and I guess it can be an episode in itself, right?
- 32:33Yeah.
- 32:34Pretty much.
- 32:35Pretty much.
- 32:36I just thought of the highlight.
- 32:37If you, kind of, how would you say like meta things, how you manage a, well, that's
- 32:45why it's called manage.py, how you manage a Django app.
- 32:48Important is the migrate.
- 32:49Of course.
- 32:50We, we all have used it.
- 32:52If you start a Django app.
- 32:53You run migrate.
- 32:54migrating.
- 32:55you're going to have a lot of stuff.
- 32:56is, you're going to have a lot of models.
- 32:59you're going to have a lot of models.
- 32:59you're going to have a lot of models.
- 32:59you're going to have a lot of models.
- 33:00the user authentication stuff, embedded.
- 33:02But for example, you can use fake initial on migrate.
- 33:06And then if the database is kind of further ahead and there's already stuff there, so it's out
- 33:11of sync, then fake initial is a way to kind of tell Django, well, if it's already in the
- 33:17database, ignore it, which can be useful.
- 33:19If, if your database is out of sync, you have low data.
- 33:22For example, if you want to have a bunch of data in your initial database, which sometimes
- 33:29is referred to as pictures, and you can give it a JSON file and pre-populate your database,
- 33:35which can be useful.
- 33:36Then we have shell, which is cool because if you do Python manage.py shell, you drop into
- 33:42the Django shell and you can play with the ORM directly.
- 33:47So you can do like from models, import bytes, and then it can do byte objects, count,
- 33:51uh, byte objects, last, whatever ORM stuff.
- 33:55So it's a nice way to...
- 33:56It's like a REPL for your web app.
- 33:58A REPL for your, for your web app.
- 34:00Yeah.
- 34:00And you can play with the objects there.
- 34:02It's, it's pretty useful.
- 34:03Yeah.
- 34:03It's really handy because if you work with the ORM, you might have some of these auto, like
- 34:09linking auto features that set values.
- 34:12And if you flip over raw to the raw database, then all of a sudden you lose all that stuff.
- 34:17that you've set up to help you kind of manage and make sure it's all consistent.
- 34:20Right.
- 34:20This way you can kind of script around in there.
- 34:23Yeah.
- 34:23But with that safety or whatever you call it.
- 34:25Yeah, exactly.
- 34:25Yeah.
- 34:26And then if you load in your production database, you can actually do that on your live database.
- 34:31So that's pretty cool.
- 34:32Yeah.
- 34:32And useful.
- 34:33You want to debug something, manage.py test to run the test.
- 34:38Not much more to say about that.
- 34:40Then most people that use Django will know.
- 34:43Create super user.
- 34:44So that, gives you a bunch of, prompts to create a user with all the permissions, which
- 34:50is useful to have to quickly log into the backend.
- 34:53I, and, and the one I really like, lastly is the Django commands.
- 34:58So you can write your own kind of use it for cron jobs.
- 35:02For example, you can write a command, which inherits from base command and you, overwrite
- 35:09the handle method.
- 35:10And then typically what, for example, we use it to, for example, we have people on the
- 35:16platform doing trials and the trials is two weeks, right?
- 35:18So after the two weeks, they are, they're done with the trial and we have to take a couple
- 35:23of settings on their profile to, get rid of that access.
- 35:27And so we have a command, that queries, all the profiles, profile objects of people
- 35:34that have an active trial and then compares, like when they started to trial with daytime
- 35:39now or time zone now, and does one action already removes the access.
- 35:44And that's a, a script that's under the app management slash commands slash script.
- 35:51And then in a Roku, we use scheduler.
- 35:53And then we say, well, every day at 9am run that script.
- 35:56And if you have a script in managed management slash commands, then managed.py recognizes
- 36:04that as, as a command.
- 36:05So if you put a script in there, then you can use it through the managed.py interface, which
- 36:10is pretty cool.
- 36:11So you can write your own cron jobs basically.
- 36:13Yeah.
- 36:13That makes sense.
- 36:13Super cool.
- 36:14Yeah.
- 36:14Yeah.
- 36:15No, that's, that's really nice.
- 36:16So it basically lets you just add these commands and then tie it into the Heroku scheduler
- 36:21or celery or something like that, that it becomes this cool cron job that knows all about your
- 36:26site.
- 36:26Yeah.
- 36:26So in Heroku scheduler, we would define every day at 9am, run Python, manage.py and then
- 36:33name of your command, which is the name of your script.
- 36:36And yeah, just like that.
- 36:38Nice.
- 36:39Yeah.
- 36:40We can, we have here on the notes, a template, some template code, how, how that would work.
- 36:45Maybe we can make a gist of that as well.
- 36:47Yeah.
- 36:47I think we have to make some gists.
- 36:48Yeah.
- 36:49All right.
- 36:50Number eight is all about middleware, which is code that runs that might see the request
- 36:57before it actually hits your end view methods or action methods or potentially changes them
- 37:02after it's already been processed and decided, but before it actually goes out the web server
- 37:08to the end user.
- 37:09So it's like a before and after view of it, right?
- 37:13Yeah, that's not super common, I think, but it's a nice way to have some sort of global
- 37:18layer in your pipeline, in the request pipeline of Django and practical example.
- 37:24We, how we used it on the platform was to remember when we had to make those GDPR changes, like with
- 37:32the regulations and stuff.
- 37:33Yeah.
- 37:33I know we talked about this and we all had to do weeks of rewriting stuff to make sure,
- 37:39even though it was in the same vein, it wasn't technically matching every rule.
- 37:43So we had to go and go through all that and make sure there was.
- 37:46Yeah.
- 37:47It could be another episode, the stories we have from that one.
- 37:50But so we made all these changes and we had to have some sort of form with already 10K users
- 37:57or more to have them kind of say yes to this at one time.
- 38:02They had to have like another acknowledgement the next time they visited the site, regardless
- 38:06of where they came into, not through the login flow or whatever.
- 38:10Yeah, because they were already a user, right?
- 38:12So they went through the registration flow.
- 38:13So we couldn't put it just there.
- 38:15We also had to do for the existing user.
- 38:17So we wrote a middleware that redirected, that kept track if they had their consent, gave their
- 38:24consent on their profile.
- 38:25And if not, it would redirect them to that page, to that form basically, where they would
- 38:30give their consent.
- 38:31And yeah, it was a nice way to enforce that login, that sorry, that redirect based on a
- 38:38profile setting basically.
- 38:39Yeah.
- 38:40So middleware was perfect there because it's kind of ruthless as it sits in front of all the
- 38:46requests.
- 38:47That's a really, really good point that it's ruthless.
- 38:49And in a good way, in a sense, right?
- 38:52Like if you were to think, okay, well, users need to make sure we got to make sure they accept
- 38:56the GDPR at this point before they go on.
- 38:58So let's check where they go and perform a byte, where they view their solution, maybe where
- 39:02they view their account and where they log in.
- 39:04And there might be some other part of the site that you forgot about, right?
- 39:08And in addition to just having to modify all those places, it's super easy to forget one
- 39:13weird edge case.
- 39:14But with middleware, every request that hits Python, that hits Django, hits this thing, right?
- 39:20And so there's no escaping it.
- 39:22You've got to accept the thing or you're getting redirected.
- 39:25Yeah, exactly.
- 39:26And yeah, I also linked here to a cool article, again, from Vitor Freitas, where he wrote a bunch
- 39:33of middleware to catch for any exception that is handling.
- 39:37He goes out to Stack Overflow.
- 39:38It's called the Stack Overflow exception troubleshooting.
- 39:41And only in debug mode, of course, it would list the top three answers.
- 39:48Stack Overflow answer, right?
- 39:49Oh, that's incredible.
- 39:50Yeah, I saw it yesterday.
- 39:52I was like, this is so cool.
- 39:53That's crazy.
- 39:55Such a cool use case.
- 39:57So I just wanted to...
- 39:58Yeah, that's a wild use case.
- 39:59How interesting.
- 40:00I'm glad you're linking to that.
- 40:01Yeah, the two places that I use that I'm really actively aware of using middleware,
- 40:06my sites.
- 40:07And Pyramid has middleware as well in Flask and so on.
- 40:10One is for things like Sentry, where it's looking at for any unhandled errors.
- 40:17And instead of just letting the server 500 page go back to the user, it'll catch it, report
- 40:22it, and then send it on, right?
- 40:24So it'll gather up all that information.
- 40:25And you basically just register that.
- 40:28You don't have to do a lot.
- 40:29And the other one is this thing I'll just throw out right through on the bonus round really,
- 40:32really quick is a thing called SecurePi, which will add all the headers that you should be
- 40:37adding for security.
- 40:39Like, do not allow my site to be embedded in an iframe on another site.
- 40:42Right?
- 40:43And the middleware will say, I don't care how you got to this request, but we're going to
- 40:47tell you, you can't embed this, whatever this is, on another site in an iframe.
- 40:52Oh, that's cool.
- 40:53Right?
- 40:53So, yeah, it's super cool.
- 40:55And it's like literally three lines of code to do it.
- 40:57But because it's middleware, you know you're not forgetting it.
- 41:00The whole site just now, all of a sudden, adds the right extra security headers.
- 41:04Yeah.
- 41:04If you're updating 20 views, then it's time to pause and reflect.
- 41:09It's a good time.
- 41:09If there's a better way, right?
- 41:10Exactly.
- 41:12Exactly.
- 41:12Yeah, yeah, yeah.
- 41:13Cool, cool.
- 41:14So speaking of better ways, number nine, you should just put your API keys and your passwords
- 41:19right inside the code, right?
- 41:20No.
- 41:20But not the Vue method, probably.
- 41:22No?
- 41:22No?
- 41:23No?
- 41:23Okay.
- 41:24You mean like committing your secret key to version control?
- 41:28I'm just kidding, yeah.
- 41:30I know you're...
- 41:33Yeah, it's...
- 41:34No, that's an important thing.
- 41:35There's stuff that you, of course, should keep out of version control.
- 41:39The way to do that is to, for example, have a .env file, which you then ignore in your .gitignore.
- 41:47And then those keys are hidden forever, right?
- 41:51But you still need to reference in your settings.py.
- 41:55And there are two packages that make it pretty friendly and easy.
- 42:01First one is Python decouple.
- 42:03And you import, for example, from decouple, import config, and maybe CSV, depending on the setting.
- 42:10And then you can just do secret key equals config, and then the key, right?
- 42:15Secret key, which is the actual secret key line in your .env file.
- 42:20So it magically knows that there's an .env file, reads it in, and extracts the key from it.
- 42:26So really nice plugin to handle your settings.
- 42:30Okay.
- 42:31Yeah, this is really cool.
- 42:32I hadn't heard of that one.
- 42:33That's neat.
- 42:34Yeah, I always recommend it to anybody using Django, really, to just pip install Python decouple and make their lives easier.
- 42:40Yeah.
- 42:42And similarly, for the database, you can use dj-database-url.
- 42:48Very similar to decouple that it uses the config method.
- 42:53And you can just give it default equals config and the database URL.
- 42:57And yeah, so as you see here, we can put the snippet in this show notes.
- 43:02The database's dictionary config section is very compact.
- 43:07You don't have to...
- 43:08Well, obviously, you have to have the right database URL string in your .env file, but it's much easier, it feels.
- 43:15Right, right.
- 43:15And database strings often contain username, passwords, host names, host ports, all the kind of stuff that you kind of not want to share.
- 43:22Yeah.
- 43:22No, that needs to be all hidden away.
- 43:26Yeah.
- 43:26And one tip I do have regarding the .env file.
- 43:30So as the .env file is hidden from version control, it won't show up on GitHub.
- 43:35So I recommend to commit a .env.example file with the same strings, with the same keys, but of course, so the same, for example, secret key, allowed host, and then, of course, not the actual data.
- 43:49But just as a way to communicate to other developers, like this is the .env file we're going to use.
- 43:54So copy this to a .env file and put in your credentials there.
- 44:00Right.
- 44:00But it's a nice way to communicate.
- 44:02Type the actual database connection string here, type the actual encryption key here, whatever, AWS key there.
- 44:08Right, because the platform has like 20 or 30 of those variables, and if somebody would start developing on that project, how do they know, right, what they said?
- 44:17Unless you run server and just start screaming about missing keys.
- 44:23Yeah.
- 44:23Until it crashes.
- 44:24Until it crashes.
- 44:25The thing is, though, sometimes those don't crash right away, right?
- 44:27Like maybe you have a MailChimp API key, and the only time that's going to scream and crash is when you actually try to register a new user, not log in an existing one, or, you know, something weird like that.
- 44:39And then like you push it to production and bad things happen.
- 44:42Yeah, it's a silent error.
- 44:43That's the worst.
- 44:44Yeah.
- 44:44Yeah, exactly.
- 44:45Yeah, it's better if stuff blows up, then it goes silent.
- 44:49Like the center five, right?
- 44:51No error should pass silently.
- 44:53Yeah.
- 44:54That's right.
- 44:55That's right.
- 44:56So, yeah, it's a big one.
- 44:57Yeah.
- 44:57Yeah.
- 44:57Yeah.
- 44:58Yeah.
- 44:59Yeah.
- 45:00Yeah.
- 45:01It's a big one.
- 45:02Build in template tags and filters.
- 45:05And yeah, there's a bunch of stuff there.
- 45:08I think it's just good to, as you're writing a lot of templates, where you're going to reference the objects that you're passing from the views.
- 45:16It's kind of handy to know how to do that.
- 45:19So I will just go over a few ones we learned about and use.
- 45:24So for example, you have a books, the list of book objects, and you look through them, but sometimes there are no books, right?
- 45:32So instead of like doing if books, look over the books and else there are no books, you can actually do for empty.
- 45:40And that's kind of a construct that Django has that if there are no objects, then it goes into the empty block.
- 45:48It's just shorter, right?
- 45:49Oh my God.
- 45:50Is that proper use for like an else block on a for foreign loop?
- 45:54Something like that.
- 45:55It might be actually.
- 45:56So you've got the syntax, you know, you've got the angle bracket percent for book in books, li curly curly book, right?
- 46:04So you're that would be and then you would say and for and that would just print out a bunch of allies with the various books that were in the list.
- 46:10Yeah.
- 46:11Like you said, you're going to want to deal with it.
- 46:13If it's not there.
- 46:14So instead of doing a whole nother test and an else, like you can just say four books, li, then percent empty.
- 46:21Sorry, there are no books and four.
- 46:23And it's all like one continuous thing.
- 46:25That's pretty cool.
- 46:26I guess there's no shame in doing an if, if else performance wise, I guess, but it's just shorter code, right?
- 46:32It's, it's more elegant.
- 46:33And, again, it's, it all goes back to like knowing about those constructs.
- 46:37Yeah. And it's more expressive. It's like, yeah, here's the thing to put when it's empty, not, oh, I see.
- 46:42It means that if this thing is false, then we have nothing.
- 46:46But if it's true, then we can go into its book list inside.
- 46:50Like, it's just, it's more clear about like, here's the empty case.
- 46:53So it's more explicit, right? Yeah.
- 46:55Yeah. And also to get really nerdy, like in those templates, you get to a lot of indents already because HTML is like that.
- 47:02If you properly format it, it's so bad.
- 47:04So that extra if else you can save theirs, it's just nice, right?
- 47:08Two to four spaces less. It's good.
- 47:10Yeah.
- 47:11Talk Python To Me is partially supported by our training courses.
- 47:16How does your team keep their Python skills sharp?
- 47:19How do you make sure new hires get started fast and learn the Pythonic way?
- 47:23If the answer is a series of boring videos that don't inspire or a subscription service you pay way too much for and use way too little, listen up.
- 47:32At Talk Python training, we have enterprise tiers for all of our courses.
- 47:36Get just the one course you need for your team with full reporting and monitoring.
- 47:40Or ditch that unused subscription for our course bundles, which include all the courses and you pay about the same price as a subscription once.
- 47:48For details, visit training.talkpython.fm/business or just email sales@talkpython.fm.
- 47:54Then what we use a lot is overriding blocks.
- 48:00So in the base template, you can define a block, for example, title, title of the website.
- 48:06And then it's again an example like Fast-Based Views of Inheritance.
- 48:10Then if you go into the child template, you can just specify a block title and then give it some other content.
- 48:16So in the base template, you kind of set the expectations.
- 48:20There are going to be blocks of ABC.
- 48:22And then in the child template, you can then actually populate those blocks.
- 48:26And I think the advantage is that sometimes a title, for example, needs to go high up in the order of HTML.
- 48:34So you have to kind of the order of the elements on the page, you have to kind of have it in your base template.
- 48:39And so it's a nice way to set it there and then come back in the child and set it to something else.
- 48:44That makes sense.
- 48:45Yeah, I love these types of things that I have on all the sites that I run.
- 48:49I have three or four that are always there.
- 48:51Obviously, the main content, right?
- 48:53Like whatever the page content is going to be, there's going to be one for that.
- 48:56This title one is super important because you want to be able to set like literally the angle bracket title, but there's not really a good way to get into that space from a base template, a drive template, right?
- 49:06It's got to like reach and poke a hole up there.
- 49:08The two other that I always have are like extra CSS and extra JavaScript.
- 49:13So like in this page, in this few pages, I need to have one more CSS file or I need to have like this one page is going to use Vue.js and be like a single page app.
- 49:22But not the rest of the stuff.
- 49:23So on this one, I'm going to like punch the Vue.js stuff at the end or something like that.
- 49:27Oh, that's cool.
- 49:28Yeah.
- 49:29For example, maybe on your checkout page, you want to have to stripe JavaScript library, but not on all pages, right?
- 49:34Yeah, not on all of them.
- 49:35So you can do that extra JavaScript and then have that script import there, although it might not be nice to have that.
- 49:42I mean, strict HTML, but you know.
- 49:45No, no, I'm pretty sure like that's probably exactly what I have.
- 49:48That's a perfect use case.
- 49:49It's something like that only appears on a few pages.
- 49:51You don't want to bundle the stripe.
- 49:53I don't even know if it makes sense in terms of their API to like minify and bundle their JavaScript with yours.
- 49:59It needs to come from their site live.
- 50:01And so yeah, exactly.
- 50:02But you want to stick it in the right place, not just randomly in the middle of the page.
- 50:06So these little like block overrides are just perfect.
- 50:09Yeah.
- 50:10Cool, cool.
- 50:11So never hard code URLs or static files.
- 50:14You can set the static at the top of your template and then just reference static and then the relative URL or URL to link to another page on your web app.
- 50:26You can just use the URL and then reference the name of the URL as you set that in your URLs.py.
- 50:33So the example here, we have curly braces percentage and then URL keyword and then the string login and that then matches to the login path in the URLs.py because we named it that explicitly.
- 50:47That's a good thing to know.
- 50:48Don't go hard code URLs because you switch domain or whatever and that will break.
- 50:54Right.
- 50:55Yeah.
- 50:55Yeah.
- 50:56Super cool.
- 50:56Other thing I like is filters.
- 50:58So I have a tags.py file and we have a bunch of register.filter decorators.
- 51:06So for example, here, we wrote one that is new with that receives a daytime and that looks if that daytime is less than seven days in the past.
- 51:18So if something is a week old.
- 51:20So and then we use it in the template.
- 51:22For example, we have by dot edit and that's again that edit field that was with the outer now.
- 51:28And then we can do pipe is new goes a bit into the weeds.
- 51:31But basically applying that is new filter on a date in the template, you can kind of play with it.
- 51:39And what we do, for example, is to give it a class and then I guess show a new image on it.
- 51:46Put a little new badge or something on it.
- 51:47Yeah.
- 51:48Uh huh.
- 51:49Yeah.
- 51:50I guess if we post the snippet, it makes more sense.
- 51:52But yeah, basically, it's a way to write a filter and you don't have to do a lot of if else and complex logic in the template.
- 52:00But you have that actually in the back end and then you can just use it as on the object in the template.
- 52:07I guess.
- 52:08Yeah.
- 52:08Let's show the code and it just.
- 52:10Yeah.
- 52:11But yeah, it's a cool way to basically put a little pipe filtering operator on there and it runs a little bit of custom code that you write.
- 52:18Yeah.
- 52:19You write it in Python.
- 52:20It runs it in templates.
- 52:21Yeah, exactly.
- 52:22Yeah.
- 52:23That's well stated.
- 52:24I think.
- 52:25Yeah.
- 52:26Yeah.
- 52:27So when I'm looking through this, you're talking about templates a lot.
- 52:30A little while ago, we talked about how it was nice to start out with some code or when you're creating these pages, maybe the database is empty, but you want some stuff in the page because it's super hard to actually see what's going on and design the pages without some content.
- 52:47So maybe some kind of lorem ipsum.
- 52:50Yeah, that's one that comes out of the box, right?
- 52:53I was so surprised that Django has lorem ipsum built into it.
- 52:58Must be in high demand, you know?
- 53:00Exactly.
- 53:01Now, it would be better.
- 53:04I mean, this is pretty good.
- 53:05It would be better if it were hipster ipsum, which is like lorem ipsum, but speaks.
- 53:12It speaks hipster speak, I guess you would call it.
- 53:17Like Stumptown, XOXO, keytars, semiotics, PBR, and MP, street art, blue bottle before they sold out, pop up mixtape and so on.
- 53:27Of course, Portland shows up in here.
- 53:29That's awesome.
- 53:30Yeah, yeah.
- 53:31So anyway, if people are looking for like lorem ipsum filler, there's actually like a lorem ipsum operation like empty as well in Django.
- 53:39Wow.
- 53:40That's really cool.
- 53:41Yeah, let me see.
- 53:42Let me pull it really quick just to see the tag.
- 53:44It is.
- 53:45Yeah, you just do percent lorem count method randomness close percent close curly.
- 53:52And boom, out it comes.
- 53:53It's beautiful.
- 53:54Yeah, like a lorem 2w random.
- 53:56Well, I'll put two random Latin words.
- 53:58How cool is that?
- 53:59Yeah, so that's really cool actually that it's built right into the templates.
- 54:03And what's nice is you don't have to have like paragraphs of junk that you're going to then delete.
- 54:07Literally like just a little bit with like I want 20 words here.
- 54:10Yeah.
- 54:11Right.
- 54:12So super cool.
- 54:13Well, remember when you were maybe was recording one time like a pretty print of how much time a comment was posted like four days and six hours ago.
- 54:23So I actually thought that was humanized and I guess humanized can do that.
- 54:27But it's actually here on the text page time since.
- 54:31Yeah.
- 54:32Oh, really?
- 54:33Like it takes a daytime and then it will like humanize it into half an hour ago, an hour ago, a week ago.
- 54:38Yeah.
- 54:39Oh, that is super cool.
- 54:40Yeah.
- 54:40Yeah, I love to see dates like that.
- 54:41Yeah.
- 54:41Yeah.
- 54:42I use that on our on our messages and forums.
- 54:45It's super nice.
- 54:46This is really nice.
- 54:47It's perfect nicer, you know, and don't have to write that logic, right?
- 54:50You just comes in a template.
- 54:51Perfect.
- 54:53That's awesome.
- 54:54We're spoiled batteries.
- 54:55All right.
- 54:56Are you ready for a bonus round?
- 54:57Yeah.
- 54:57Yeah.
- 54:58Yeah.
- 54:59Let's do a bonus round.
- 55:00Let's do it.
- 55:01All right.
- 55:02So, yeah.
- 55:03Bonus number one hit us.
- 55:04Okay.
- 55:05And I've not used this that much, but playing with it yesterday, it's actually pretty cool.
- 55:07It's a Django extensions.
- 55:09And I will just highlight a few things you can do.
- 55:12You can do Python, manage the pie graph models, and then minus a, minus O, and then a PNG.
- 55:19And it will make a PNG or ping, whatever you call it, of all your models in your database.
- 55:27So it'll create like a UML diagram of your Django ORM models, basically.
- 55:32Yeah.
- 55:33Something like that and how they're linked together.
- 55:34Yeah.
- 55:35Mine is like super small.
- 55:36I know if it's formally UML, but yeah, it's definitely more or less.
- 55:39Yeah.
- 55:40It's so small because there are so many models in our thing, but pretty cool.
- 55:44Exactly.
- 55:45Like how you can visualize that, I guess, if you would, you know, get more developers on
- 55:49board.
- 55:50Yeah.
- 55:51And you talked about shell.
- 55:52Yeah.
- 55:53I mentioned shell before, and there's actually a shell underscore plus that comes with the Django
- 55:57extensions.
- 55:58And then you can also give it dash as IPython, and then you drop into an IPython shell.
- 56:03And it also imports all your models.
- 56:06So you don't have to import them manually, but it's pretty convenient.
- 56:09And not part of the Django extension, but I did want to mention is a plugin called Django
- 56:16dash tiny MCE, which gives you a rich text editing field.
- 56:21And it's pretty sweet.
- 56:22Yeah.
- 56:23Yeah.
- 56:24So tiny MCE is like a WYSIWYG, what you see what you get, HTML editor, right?
- 56:28Yes.
- 56:29Yeah.
- 56:30So this like brings it in or something like makes it easy to use in Django.
- 56:32Yeah.
- 56:33Well, you would use the HTML field.
- 56:35So from tiny MCE dot models import HTML field.
- 56:38So it would of course cause another migration, but yeah, it's, it's pretty easy to use.
- 56:43And, it's a huge improvement for the end user.
- 56:45Right.
- 56:46So, yeah, that's super cool.
- 56:47You know, while you're on the topic of that, I'll throw one more out.
- 56:50There is simple MDE.com.
- 56:52So tiny MCE is cool, but I think the ultimate outcome is HTML and simple MDE is a beautiful
- 57:01Markdown editor.
- 57:02That's just pure JavaScript.
- 57:03Yeah.
- 57:04Pure client side JavaScript.
- 57:05It has like hotkeys.
- 57:07It has side by side secretized scrolling all like even the Markdown, like the text in Markdown,
- 57:13even though it's plain text, it's like the headings are bigger than the code bits and whatnot.
- 57:19It's, it's really easy to throw it on a text area.
- 57:21Looks super nice.
- 57:22Yeah.
- 57:23Yeah.
- 57:24Cool.
- 57:25Yeah.
- 57:26It's very nice.
- 57:27Just turn off spell checker.
- 57:28It'll tell you everything's misspelled.
- 57:29All right.
- 57:30Bonus number two.
- 57:31Keep it flying.
- 57:32salary.
- 57:33Yeah.
- 57:34Salary really want to mention that because, we're especially in the enterprise where I
- 57:38see Django, I see salary.
- 57:39Like it's just always tasks that are, that have to be offloaded and be done async wise.
- 57:45It makes sense.
- 57:46Right.
- 57:47Right.
- 57:48It's not meant to be done in the context of a direct request.
- 57:51I learned this the hard way with my site.
- 57:53So there's a backend that will let me email the people in a particular course.
- 57:59Like, so I could go, if there's an update, like a problem with the course, I can go into
- 58:02that course to email everybody who subscribed here.
- 58:05And then eventually the first time I did, I didn't really think this all the way through.
- 58:08I went in and I filled out an email, I hit go and it just sat there and it spun and it
- 58:13spun and it spun.
- 58:14And then eventually it timed out after like 20 seconds and crashed.
- 58:17I'm like, Oh no.
- 58:18So it emailed like thousands of people, but I don't know who actually got the email.
- 58:23Cause I said everybody and it got partway through and then crashed.
- 58:26And so then what I do, I email them again.
- 58:28The first half will get the double.
- 58:29The second half didn't get it at all.
- 58:31Like I'm just like, what have I done?
- 58:33What a fool.
- 58:34Yeah.
- 58:34So don't do that.
- 58:35That's a bad experience.
- 58:36But now your Sunday evening will be shorter, right?
- 58:38Because you know that ORM and you can, but yeah, you would have to write some sort of
- 58:42script to see who got emailed or not, you know?
- 58:45Yeah, exactly.
- 58:46Like scrape the logs or something, right?
- 58:48Like I basically decided, well, I guess the other half of the class is just not getting that
- 58:52message.
- 58:53I'm sorry.
- 58:54Yeah.
- 58:54So now it's salary, right?
- 58:55You would click send and you would be immediately back at the, from the request cycle.
- 59:00So back at your interface.
- 59:02Right.
- 59:03Dump it in a queue, throw it at salary and say, start emailing these people.
- 59:06It's on the queue and it's all happening in the background.
- 59:08Yeah.
- 59:09So that's, then, you know, for, for other things like heavy file processing, anything intensive,
- 59:16send it to you, right?
- 59:18Because the user shouldn't be waiting for that.
- 59:21I think even for some of my stuff, I started doing logging on a queue.
- 59:24I'm just like, I don't want this, whatever this is, I don't want it to like be part of
- 59:28this request.
- 59:29I'm just going to throw it over there and we'll get to it in a minute.
- 59:31You know what I mean?
- 59:32Yeah.
- 59:33Yeah.
- 59:34Yeah.
- 59:35And a quick debugging tip.
- 59:36If you want to debug salary, actually, sometimes it's convenient to not send it to a queue
- 59:40and have it as part of your main process.
- 59:42And you can set salary_always_eager equals true in your settings.
- 59:48And then all the, then it doesn't go to a task queue anymore, but it goes straight to your main console where you have run server running.
- 59:55And it's just easier to debug.
- 59:57So I just want to mention that tip that it's not very well documented, but it definitely helped me on a few occasions.
- 1:00:04Yeah.
- 1:00:05Very cool.
- 1:00:06That's awesome.
- 1:00:07I definitely need to make better use of salary and what I'm doing as well.
- 1:00:08All right.
- 1:00:09Last one.
- 1:00:10This one I just threw on there.
- 1:00:11So I'll tell you about it, Bob.
- 1:00:12I told you that there's like all these headers you should be putting into your code and to your HTTP response.
- 1:00:19And if you go look at the OWASP top 10 web vulnerabilities, the open web security group or whatever that OWASP stands for, they go through and they keep track of all the problems.
- 1:00:30Right.
- 1:00:31And some of those can be, you know, cross site scripting, embedding your stuff and something that looks like your site, like an embed something that basically is your site in an iframe, but then put a transparent overlay that captures keystrokes for like say username and password, all sorts of bad stuff like that.
- 1:00:46So there's all these headers you should send back.
- 1:00:48So if you use this thing called secure PI, which is a GitHub.com type slash type error slash your dot PI.
- 1:00:54And I don't know how they got this, but it's pip install secure, which is incredible that that's still available.
- 1:00:59But the idea is it just on any of these frameworks, including Django, it will just as middleware, just drop in all the changes you need.
- 1:01:08And it's like for Django, let's see, what does it take?
- 1:01:11Oh, that's just the Django.
- 1:01:12Just the Django.
- 1:01:13There's a super simple integration on how to set it up.
- 1:01:16I had to pull up the docs.
- 1:01:17Anyway, it's really super easy.
- 1:01:19And then you get things like strict transport security, cross site protection, X frame options, the same origin, like all those kinds of things that you would like to have that you might forget.
- 1:01:28And because it's middleware, it's just like magic.
- 1:01:30Wow, that's really cool.
- 1:01:31Yeah.
- 1:01:31And it works with like 15 different frameworks or 10 different frameworks.
- 1:01:35It's really almost no matter what you're using, it works with it, you know?
- 1:01:38Yeah.
- 1:01:39Wow.
- 1:01:40And you just added to middleware with app dot secure middleware dot set secure headers.
- 1:01:44Yeah.
- 1:01:45Really cool.
- 1:01:46Yeah.
- 1:01:47It's literally like one function, like a simple decorator that you write more or less simple, simple middleware.
- 1:01:53Yeah.
- 1:01:54I just added in there and off it goes.
- 1:01:55So it integrates just like you'd expect.
- 1:01:57Anyway, that's just, it's so easy.
- 1:01:59It's so easy to add that security.
- 1:02:01And who knows if something else comes out that you're supposed to start doing, you know, secure dot PI might get updated and your site will just magically be more secure.
- 1:02:08And you don't have to think about that, which is always nice.
- 1:02:10Yeah.
- 1:02:11Theoretically.
- 1:02:12Pretty cool.
- 1:02:13Thanks.
- 1:02:14Yeah.
- 1:02:15Yeah.
- 1:02:16Yeah.
- 1:02:17You bet.
- 1:02:18Of course.
- 1:02:19Of course.
- 1:02:20All right.
- 1:02:21Well, we did it.
- 1:02:22We didn't take four hours to cover that, even though it did take some, some time.
- 1:02:23I mean, we, you guys who are listening, you can't see there's a ton of details.
- 1:02:26We kind of skipped over.
- 1:02:27We could have gone into it.
- 1:02:28Right.
- 1:02:29Like, like you said, with manage that PI is probably its whole episode.
- 1:02:32For example, we've got Django test, but Django rest framework.
- 1:02:36We got wagtail.
- 1:02:37We got century.
- 1:02:38Then go channels.
- 1:02:40We haven't even touched on authentication.
- 1:02:42There's all sorts of stuff.
- 1:02:43Right.
- 1:02:43That you didn't mention century.
- 1:02:45You didn't mention.
- 1:02:46I did.
- 1:02:46But yeah, that was an official item.
- 1:02:48But yeah.
- 1:02:49Yeah.
- 1:02:50Yeah.
- 1:02:51Yeah.
- 1:02:52Century is cool.
- 1:02:53There were some 500 errors.
- 1:02:54We would have never known about.
- 1:02:55Well, not affiliated or anything.
- 1:02:56Oh, it's real.
- 1:02:57Yeah.
- 1:02:58They're so rare.
- 1:02:59They're so rare.
- 1:03:00And they're under weird edge cases.
- 1:03:01And if you run a website, you should definitely install something like century or roll bar or something like that, where you get notifications anytime there's an error.
- 1:03:10At first, it's annoying.
- 1:03:11Like there's certain things that you can't control.
- 1:03:14Well, somebody will try to, you know, post a binary thing to some part of your API where it expects like Latin characters.
- 1:03:22You'll get like a non Latin parse area.
- 1:03:24Like, okay, well, there's nothing I could do about this, but you could start muting those types of things.
- 1:03:28And eventually you'll be like, oh, I got these errors.
- 1:03:31And literally, I would say more, certainly more than one time, I have seen an error come in over one of those channels, figured out what was going on, fixed it and then sent a message to the user and said, I'm sorry, I saw you had this error.
- 1:03:44Here's I fixed it.
- 1:03:45And they're like, well, I was just about to write you.
- 1:03:47This is crazy that you actually, I didn't even tell you there was an error and you fixed it and contacted me.
- 1:03:52That's so cool.
- 1:03:53Right?
- 1:03:53Yeah.
- 1:03:54Yeah.
- 1:03:55Because often they 500 error, this sucks and they go away.
- 1:03:57Right.
- 1:03:58Exactly.
- 1:03:59Exactly.
- 1:04:00And now you're proactive about it.
- 1:04:01So that, that, that really makes a difference.
- 1:04:03Yeah.
- 1:04:03And even if they're mad and they go away and they've lost faith, whatever, like, you know, there's nothing you can do to change the past, but it's, your site is better every time you catch one of these errors that you wouldn't have caught.
- 1:04:14So yeah.
- 1:04:15But I agree that a lot of time it's like edge cases, but sometimes there's something that, that might indicate a bigger problem.
- 1:04:20That's, that's good to know.
- 1:04:21Right.
- 1:04:22Or you deploy something that's bad and all of a sudden it's like gone crazy and your email and text messages are full.
- 1:04:27You're like, whoa, whoa, whoa, I better go check this out.
- 1:04:29It's not good.
- 1:04:29Yeah.
- 1:04:30It feels a bit safer, right?
- 1:04:31To do a Git push to having that, it's a bit safer.
- 1:04:35Yeah.
- 1:04:36Yeah.
- 1:04:37At least you'll see the smoke if it catches on fire.
- 1:04:39Yeah.
- 1:04:40Yeah.
- 1:04:41All right.
- 1:04:42Well, these are really fun things to cover, Bob.
- 1:04:44And I think people really enjoy them.
- 1:04:46We can put together some of them just, and we'll try to link to the others in the show notes.
- 1:04:50Yeah.
- 1:04:51Cool.
- 1:04:52We'll do.
- 1:04:53I'll try to answer the final two questions.
- 1:04:54Oh,
- 1:04:55so if you're going to write some Django code, what editor to use?
- 1:04:58Yes.
- 1:04:59I still use him.
- 1:05:00Yeah.
- 1:05:01I don't go away.
- 1:05:02Yeah.
- 1:05:04It's, I always say it's a steep learning curve, right?
- 1:05:07the beginning was very awkward using that editor, but it has this compound effect.
- 1:05:13Once you get to a lot of shortcuts and you just become pretty fast in it and it's very
- 1:05:18convenient, but I'm missing out on all the ID features, I guess.
- 1:05:21Yeah.
- 1:05:22Yeah.
- 1:05:23That's cool.
- 1:05:24You want to hear a little Vim joke?
- 1:05:25Yeah.
- 1:05:26Yeah.
- 1:05:27Okay.
- 1:05:28Yeah.
- 1:05:29I might.
- 1:05:30Yeah.
- 1:05:31So how, how do you generate a random string?
- 1:05:32Yeah.
- 1:05:33I know.
- 1:05:34Trying to exit it.
- 1:05:35You put a first year computer science student in Vim and ask them to exit.
- 1:05:39Yeah.
- 1:05:40That's so good.
- 1:05:41Yeah.
- 1:05:42Yeah.
- 1:05:42It's all good.
- 1:05:43Right.
- 1:05:44And then we covered so many packages here, but maybe just throw out a couple of packages
- 1:05:48that you're like, man, people need to know about this thing.
- 1:05:50Yeah.
- 1:05:51I'm going to, kind of abuse the fact that we had to leave some out to pull them in here.
- 1:05:57So we didn't talk about, the bonus round, the bonus bonus.
- 1:06:00So Django all out is a great package or plugin to, yeah, to really make your authentication
- 1:06:07in Django easy.
- 1:06:08And, and Django rest framework.
- 1:06:09And, and Django rest framework.
- 1:06:11I still find it a great, great package offer to, to build APIs in Django.
- 1:06:15But if it doesn't have to be Django, then let's throw in Python date util, which is really cool.
- 1:06:22Yeah.
- 1:06:23Yeah.
- 1:06:24Python date util is awesome.
- 1:06:25I love its ability to parse stuff without me.
- 1:06:27I think too much about it.
- 1:06:28The fuzzy, fuzzy parsing, right?
- 1:06:30The, yes, exactly.
- 1:06:31It almost always works.
- 1:06:33It is so nice.
- 1:06:34Because you don't have to remember SDRP time.
- 1:06:37You just throw it into parse and it magically, converts it to a daytime object.
- 1:06:43Right?
- 1:06:44Yeah.
- 1:06:45Yeah, absolutely.
- 1:06:46There's some site and I can't remember what it is.
- 1:06:47I know I've covered on Python bytes, but unfortunately I'm not tracking it down right now.
- 1:06:51There's a site that will let you type in a human readable string and then tell you the format string that goes with it.
- 1:06:57Oh, it's so nice.
- 1:06:58Oh no.
- 1:06:59That's cool.
- 1:07:00Yeah.
- 1:07:00So you type like Wednesday at two, 2 PM and it'll, it'll actually pull it up.
- 1:07:05Nah, I can't find it.
- 1:07:07Oh, well anyway.
- 1:07:08Yeah.
- 1:07:09That's cool.
- 1:07:10Long story short.
- 1:07:11This is a great package.
- 1:07:12If you're parsing things, Python dash date util.
- 1:07:14Yeah.
- 1:07:15And now can I mention another one?
- 1:07:16Go for it.
- 1:07:17So if you're working a lot with databases, which obviously happens when you, when you do web development,
- 1:07:20and Django for Postgres, PG CLI.
- 1:07:24PG CLI is like a way nicer interface than PSQL.
- 1:07:28Yeah.
- 1:07:29So just pick install it and you will have a lot more fun working with Postgres databases from the command line.
- 1:07:35Nice.
- 1:07:36Do you know one?
- 1:07:37I know one that you recommended was SQLite browser at sqlitebrowser.org, which is pretty cool, but that's just for SQLite.
- 1:07:43Right.
- 1:07:44Have you come across Beekeeper Studio at beekeeper studio.io?
- 1:07:48No.
- 1:07:49Oh, my goodness.
- 1:07:51So this is a free open source database GUI for Postgres, SQLite, SQL Server, presumably also Oracle works on all the platforms.
- 1:08:03And man, it is cool.
- 1:08:04You can even have like saved queries.
- 1:08:06You typically run.
- 1:08:07It has auto complete all kinds of stuff.
- 1:08:09Wow.
- 1:08:10That looks very nice.
- 1:08:11It looks good.
- 1:08:12Right.
- 1:08:13It's something you look like you'd want to use.
- 1:08:15Yeah.
- 1:08:16Like even just an auto complete query thing.
- 1:08:19Composer is pretty cool.
- 1:08:21So anyway, we need to link to that as well.
- 1:08:23Yeah.
- 1:08:24We're going to throw out some database management stuff.
- 1:08:26That's a really good one.
- 1:08:27I should definitely.
- 1:08:27I'll put that in there as well.
- 1:08:28Cool.
- 1:08:29All right.
- 1:08:30We covered a lot of stuff.
- 1:08:31What a whirlwind.
- 1:08:32But it was really fun.
- 1:08:33So yeah, I guess final call to action.
- 1:08:36People are all excited about what you've talked about.
- 1:08:38Also, maybe they're interested to see how you've taken some of these ideas and put them into action over at code challenges.
- 1:08:44You know, final call action and what what should people do?
- 1:08:46Yeah.
- 1:08:47So we don't have bite exercises on Django.
- 1:08:50That was a bit hard, but regardless.
- 1:08:52Yeah, it's hard to set up the whole server and database infrastructure in like a little tiny bit.
- 1:08:57Right.
- 1:08:57That might be possible.
- 1:08:58I think we have to have a flask bite.
- 1:09:00So I think it's possible because we can install any packages on our AWS land us.
- 1:09:05Right.
- 1:09:05Right.
- 1:09:06But regardless, go to code challenge.es and go write some code.
- 1:09:09That's the best thing you can do if you want to learn Python.
- 1:09:12And you can also reach out to me by our slack.
- 1:09:16So if you go to by by the yes, they're on the resources.
- 1:09:19There's a community link.
- 1:09:20Anybody join your slack there?
- 1:09:21Yeah, that's totally for the community.
- 1:09:23You've got a really, really vibrant and self sustaining slack channel for Python developers like more than most other places I've seen, which is really cool.
- 1:09:31I don't know.
- 1:09:32You've got thousands of people in there, right?
- 1:09:33Yeah, I think we crossed the 2000 mark.
- 1:09:36And yeah, it's awesome how people are interacting, responding, helping each other.
- 1:09:42It's it's it's such a nice place.
- 1:09:44Yeah.
- 1:09:44So they got a code challenge dot es slash community.
- 1:09:47Is that it?
- 1:09:48No, there is a slack but a logo on the platform.
- 1:09:52But if you just want the link, then you can also just go to by by the yes.
- 1:09:57And under the resources drop down, there's a community link.
- 1:10:00And right, right, right.
- 1:10:01Because slack sometimes the invite link.
- 1:10:03Yeah.
- 1:10:04Don't get me started.
- 1:10:05Expires or whatever.
- 1:10:06Don't get me started on getting joined into slack, man.
- 1:10:09Yeah.
- 1:10:09So we just have a dedicated page.
- 1:10:11And if you go to by by by by the yes, then that always works.
- 1:10:15Awesome.
- 1:10:16All right.
- 1:10:17Well, thank you for taking the time to come on here and talk all about this.
- 1:10:20And congratulations on going full time on your project.
- 1:10:23Awesome.
- 1:10:24Good work.
- 1:10:24Thank you.
- 1:10:25Thanks for having me.
- 1:10:26It was great fun.
- 1:10:27Yeah, you bet.
- 1:10:28As always.
- 1:10:29See you.
- 1:10:30Bye.
- 1:10:31This has been another episode of talk Python to me.
- 1:10:33Our guest on this episode was Bob builder boss, and it's been brought to you by Linode
- 1:10:37and us over at Talk Python Training.
- 1:10:39Start your next Python project on Linode's state of the art cloud service.
- 1:10:44Just visit talkpython.fm/linode, L I N O D E.
- 1:10:49You'll automatically get a $20 credit when you create a new account.
- 1:10:52Want to level up your Python?
- 1:10:54If you're just getting started, try my Python jumpstart by building 10 apps course.
- 1:10:59Or if you're looking for something more advanced, check out our new async course that digs into all the different types of async programming you can do in Python.
- 1:11:07And of course, if you're interested in more than one of these, be sure to check out our everything bundle.
- 1:11:12It's like a subscription that never expires.
- 1:11:14Be sure to subscribe to the show.
- 1:11:16Open your favorite podcatcher and search for Python.
- 1:11:18We should be right at the top.
- 1:11:20You can also find the iTunes feed at /itunes, the Google play feed at /play, and the direct RSS feed at /rss on talkpython.fm.
- 1:11:28This is your host, Michael Kennedy.
- 1:11:31Thanks so much for listening.
- 1:11:32I really appreciate it.
- 1:11:33Now get out there and write some Python code.
- 1:11:35Thank you.