Latest / Talk Python To Me / #301: Deploying and running Django web apps in 2021
Transcript
- 0:00Have you been learning Django and now you want to get your site online?
- 0:03You're not sure about the best way to host it or the trade-offs between the various options?
- 0:07Maybe you want to make sure your Django site is secure.
- 0:09On this episode, I'm joined by two Django experts, Will Vincent and Carlton Gibson.
- 0:15Talk about deploying and running Django in production,
- 0:18along with recent updates in Django 3.2 and beyond.
- 0:21This is Talk Python To Me, episode 301, recorded January 19th, 2021.
- 0:27Welcome to Talk Python To Me, a weekly podcast on Python,
- 0:43the language, the libraries, the ecosystem, and the personalities.
- 0:46This is your host, Michael Kennedy.
- 0:48Follow me on Twitter where I'm @mkennedy,
- 0:50and keep up with the show and listen to past episodes at talkpython.fm,
- 0:54and follow the show on Twitter via at Talk Python.
- 0:57This episode is sponsored by Square and Linode.
- 1:00Please check out what they're offering during their segments.
- 1:02It really helps support the show.
- 1:04Before we get to our discussion, just one quick announcement.
- 1:07We started live streaming the recordings of Talk Python To Me episodes on YouTube.
- 1:11If you're part of the live stream, you'll have a chance to ask questions,
- 1:14and your comments might get featured on the air.
- 1:16Just visit talkpython.fm/youtube to subscribe to the channel
- 1:19and see upcoming and past live streams.
- 1:21Now, on to the show.
- 1:22So, Carlton, Will, welcome to Talk Python To Me.
- 1:27Again, welcome back, guys.
- 1:28Yeah, thank you.
- 1:29You came on our show, and I was on your show three years ago.
- 1:32So, Carlton's first time on your show.
- 1:34Talk Python newbie.
- 1:35It was great to have you on the show before, Will.
- 1:38And we talked about Django then,
- 1:39and I suspect it won't surprise people with you and Carlton here
- 1:43that we may touch on Django.
- 1:45I think we've got to talk about Django a little bit.
- 1:47A little bit.
- 1:47Carlton, tell people who you are.
- 1:49I'm a Django fellow, so what that means is I help to maintain the framework.
- 1:53A framework the size of, oh, you've got me on Twitter there.
- 1:55Oh, yeah.
- 1:56Carlton Gibson on Twitter and on GitHub, numerous other places probably.
- 2:00But a framework the size of Django's, it just simply doesn't get maintained
- 2:04on purely volunteer effort.
- 2:06So, there's a body called the Django Software Foundation,
- 2:08which Will's on the board for.
- 2:09He can tell you a bit about that in a second.
- 2:11But they are a charitable foundation, which, well,
- 2:14they collect money from donations from GitHub sponsors,
- 2:17and you can donate on djangoproject.com.
- 2:19And then the main thing they do is they contract the fellows,
- 2:22which is myself and Mariusz Felisiak, who's my colleague now.
- 2:25And we do that.
- 2:26I don't know.
- 2:27What do we do?
- 2:28We triage the tickets.
- 2:29We do pull request review.
- 2:30We do handle security issues.
- 2:32We handle the releases, not least the alpha releases today.
- 2:35So, today, literally today, we released Django 3.2 Alpha 1.
- 2:39Fantastic.
- 2:39Is that the very first 3.2 release?
- 2:41That's the first one.
- 2:42So, that's like if you've got a Django project and you've got CI,
- 2:45you download it now and you run it on your CI
- 2:47and you tell us all the things we broke.
- 2:49Better before we release the final.
- 2:50You know, it's much better during the alpha pre-release period
- 2:53than, you know, just after 3.2 final, you go,
- 2:56hey, everything's broken.
- 2:57Yeah, you really need people to test it now
- 3:00before it's too late, right?
- 3:01Yeah, but yes, it's quite exciting
- 3:03because the last couple of weeks have been building
- 3:04towards the feature-free.
- 3:05So, the alpha marks the feature-free.
- 3:07So, over the pre-release period now,
- 3:09we'll merge bug fixes in the new features.
- 3:12So, anything that people find and report will fix
- 3:15and get out before the final.
- 3:16But there's no new features going into 3.2.
- 3:19So, on Thursday, just gone, I branched the stable branch
- 3:22for 3.2, which will be, that's Django 3.2.
- 3:25And it will be that for the next three years
- 3:27because the long-term release gets quite,
- 3:29the long-term support release, which 3.2 is,
- 3:31gets three years of support.
- 3:33That's really great.
- 3:34All right, we're going to definitely have to come back to that,
- 3:35but also, welcome, Will.
- 3:37Tell everyone about yourself.
- 3:39Real briefly, you know, you were on the show a while ago
- 3:42and we talked, I believe it was learning Django
- 3:43we spoke about, right?
- 3:44I've been involved in Django, it's the time.
- 3:46So, I'd written, I think, a couple books.
- 3:48So, I have three books,
- 3:49Django for Professionals and APIs.
- 3:52And the last two years, I've been a member of the Django Software Foundation board.
- 3:55About two people who were voted in,
- 3:57who play a prominent role in the community one way or another.
- 4:00And then the board is seven people annually voted on
- 4:03who managed Django itself, which is a non-profit.
- 4:05About that later.
- 4:06So, yeah.
- 4:08And I have now a website, learndjango.com,
- 4:10which is an online version of additional content.
- 4:12But in addition to having a podcast with Carlton, Django Chat,
- 4:16since he's a fellow, which is contracted by the board,
- 4:19we have another touchpoint, as if we didn't need more.
- 4:22Exactly, yeah.
- 4:23So, I was on your show a while ago and that was super fun.
- 4:26I really enjoyed our conversation there.
- 4:28And, you know, maybe just tell people quickly about your podcast.
- 4:32What kind of stuff do you cover there?
- 4:33Obviously Django, but, you know, where do they find it?
- 4:35What do they cover?
- 4:36Okay, so we get people on from the community.
- 4:38It's kind of an interview type basis.
- 4:40We get someone on.
- 4:41It's fortnightly now.
- 4:42We were doing it every week, but, you know,
- 4:44not like you, Michael, we can't keep it up forever.
- 4:47So, we've gone fortnightly,
- 4:48which has taken a bit of pressure off with COVID
- 4:50and, you know, the kids off school and all of that.
- 4:52But we get, you know, people who've contributed to Django
- 4:55or people who are using Django in their business and talk about it.
- 4:58So, it's Django Chat.
- 4:59It's chatting about Django.
- 5:01It's chatting about Django, yeah.
- 5:01Yeah, yeah, yeah.
- 5:03It's chatdjango.com.
- 5:04I think recreating a little bit of what you would have at a Django
- 5:06event.
- 5:07So, these are annual events.
- 5:08So, we started after I went to my first DjangoCon and met Carlton
- 5:12and was like, why can't I talk to people about Django more often?
- 5:15And at the time, there wasn't a Django podcast.
- 5:17So, yeah, we've gotten to interview really my dream list of guests.
- 5:21I mean, we had...
- 5:22Actually, I was just talking to someone else who works at Stripe,
- 5:25which is still running on Sinatra, which is a Ruby thing.
- 5:27And I was like, yeah, yeah.
- 5:28I've talked to DHH because he's came on our shows.
- 5:31We talked about Rails versus Django.
- 5:32We had Carl Meyer on, who's at Instagram, was formerly DjangoCore.
- 5:36All the...
- 5:37Basically, everyone...
- 5:37Almost everyone we'd want to talk to who's involved in Django is willing to come on and
- 5:41share their story.
- 5:41So, I think it's a really nice connector and educational for us, too.
- 5:45I do as well.
- 5:45And you're just sort of a sidebar for our show here.
- 5:48Being all of us fellow podcasters, I think it's really interesting the role that podcasts
- 5:54play in keeping connections to the broader tech community when we can't go anywhere.
- 5:59I mean, even if you weren't typically going to conferences or meetups, you could still go
- 6:04to work and see other people, right?
- 6:06It's just first when COVID hit, I was like, I'm just...
- 6:10I'm not traveling anywhere.
- 6:11I'm not taking my kid to school or anything like that.
- 6:13So, there's no natural place.
- 6:15Here, I'm stuck for 45 minutes.
- 6:17I'm going to just listen.
- 6:18But as it's drawn on, I've started to listen to shows, especially with multiple people trying
- 6:22to bring sort of a normalcy.
- 6:25And I get to kind of hang out with these people, even though they don't respond to me.
- 6:28I still get to hang out with them.
- 6:29And I think that's a really interesting societal thing that's happening right now.
- 6:33Yeah.
- 6:33I think it's beneficial across the board.
- 6:35I mean, probably like you all, I listen to podcasts outside of tech as well.
- 6:39And it's sort of like people I'd want to sit in on their conversations anyways.
- 6:43So, for me, it's probably my primary media consumption aside from books.
- 6:47Yeah.
- 6:48But I mean, I'm not reading ancient Greek like Carlton.
- 6:49Carlton has a PhD and all that.
- 6:51We're going to talk about specifically deployments on Django.
- 6:55I mean, we can go on and on about obviously all the intricacies of Django.
- 6:58But I think suffice to say, I'm an educator and on the board and Carlton's a fellow.
- 7:02So, he makes the releases happen, including 3.2 Alpha, which just dropped today.
- 7:06And I guess you mentioned LTS.
- 7:08So, that's confusing to non-Django people.
- 7:10So, since having fellows like Carlton, Django has a pretty rapid release cycle where it's
- 7:15every nine months or so.
- 7:17So, there was 3.0, 3.1, 3.2.
- 7:19This December, I think Carlton is 4.0.
- 7:21One of those is a long-term service release.
- 7:25So, that'll last two and a half years.
- 7:27So, if that is a three years.
- 7:29Yeah, it's on.
- 7:30There's a link on the Django project site.
- 7:32So, that's a way that.
- 7:33So, Django doesn't really have.
- 7:34It's rare to have breaking changes these days.
- 7:36But the LTS is designed to help people who can't keep up with that cycle stay up to date.
- 7:41Though we have a lot of podcasts and opinions about why you should always stay up to date.
- 7:44And it's worth it.
- 7:45Yeah.
- 7:45Because that's one of the most rare things you can do.
- 7:48Because as Carlton mentioned, there's bug fixes constantly.
- 7:51So, there's 3.1.1, 3.1.2.
- 7:53There'll be 3.2.
- 7:54Then there'll be 3.2.1 a month later or so.
- 7:57I'm a big advocate of, you know, if you possibly can get on the latest major release.
- 8:01So, hanging out historically, the long-term release was really important.
- 8:05The LTS release was really important.
- 8:06Because there were breaking changes, right?
- 8:09In each major version of Django, there were new things.
- 8:11And it was difficult to keep.
- 8:12But that's not the case anymore.
- 8:14It's really easy to update.
- 8:15So, I'm a big advocate of that.
- 8:17Now, and then when I, you know, I talk to fellow people in the Django community,
- 8:20they're like, well, you know, I work in the real world.
- 8:22And you can't always keep up on the latest major version.
- 8:25So, for those folks, then, you know, the LTS is a really good option.
- 8:29Because it's once every three years.
- 8:31You know it's coming.
- 8:31Yeah.
- 8:32You get a six-month window of overlap of support.
- 8:34So, the old LTS gets six months of security release after the release of the new LTS.
- 8:40And that's your window to update.
- 8:41Well, I think that running and maintaining software built upon frameworks like Django,
- 8:46it falls into two categories for me.
- 8:48It falls into, here's something that we have a team or at least somebody dedicated to owning
- 8:53this project.
- 8:54And we care about its ongoing life.
- 8:56And then we have the ones that are the, oh, please don't touch it.
- 9:00And the, oh, please don't touch it is we've long since stopped developing that.
- 9:04Maybe the person who developed it left.
- 9:06But it's still important.
- 9:08And we don't want to break it.
- 9:09It's working right now.
- 9:11But if you touch it and you break it, you've now adopted it.
- 9:13You know what I mean?
- 9:14Like, it's that thing that just, it runs.
- 9:17It's like if you break the build.
- 9:18Yes, but, but worse because it's legacy build.
- 9:21So, to me, I feel like that please don't touch it side, the LTS make perfect sense for them.
- 9:26Yeah, entirely, entirely.
- 9:27The way I like to think of it is, is this a thing that you're feasibly going to add new
- 9:32features to?
- 9:33And if you're feasibly going to add new features to, then you should be on the latest major
- 9:36version.
- 9:37And because it's only, it's once every eight months, you need to allocate a day or two to
- 9:41keep up, to, you know, fix up, download the new version, run the test suite, see the
- 9:45deprecation warnings, fix the deprecation warnings.
- 9:48You know, maybe you have to wait a couple of weeks for a dependency to update and, and
- 9:52then you can push forward.
- 9:53And that's once every eight months, that process.
- 9:55And if you're adding new features, if it's a live project, ideally you'd be there.
- 9:59There's something which you just need to keep running for the long run.
- 10:01You know, you could do that much less frequently.
- 10:04Right.
- 10:04But it allows people who have that, please don't touch it.
- 10:07But, oh, there's a security problem.
- 10:09If there's no LTS and there's a security problem, then not only do they have to figure out how to
- 10:13redeploy the fix, they've got to say, well, we didn't touch it for three years and it doesn't
- 10:18quite work the same.
- 10:19So then you get into the discussion of, well, what's the risk?
- 10:23Will they really, it's just Java swing.
- 10:25I mean, come on, what's the problem, right?
- 10:27How bad could that go with, you know, like the entire world's credit report speed?
- 10:32Now that we're in Python 3 world, Django was part of that.
- 10:35It's really beyond the security thing.
- 10:37It's also all the ecosystem around Django, the third party packages.
- 10:40Like a lot of times, if you look at their project that says, I can't update, why can't you update?
- 10:45They did two things.
- 10:46They're using a third package, which falls into that, you know, touch it, you broke it situation.
- 10:52Or they did something custom at one point.
- 10:54They went off the guardrails and the bill comes due.
- 10:58I mean, it's so tempting.
- 10:59Actually, I want to, speaking of going off the guardrails, quick note that Django just passed
- 11:04Flask to have stars, which is a really poor metric of popularity, but nonetheless, we'll take it.
- 11:09Yeah, congratulations.
- 11:10That's awesome.
- 11:11It's very easy to, you know, spin up a couple API endpoints and boom, you're using Flask.
- 11:16That's a very different thing.
- 11:17That's like, as DHH would say, that's a Lego versus the Lego truck that is a framework like Django.
- 11:22And anecdotally, a lot of places use Flask, but in terms of a big site that's all Flask, that's much less common than all Django.
- 11:31Yeah.
- 11:31Well, I was thinking about this morning and it, you know, the Flask and Django are pretty neck and neck in terms of popularity.
- 11:38They're not on GitHub.
- 11:40Yeah, yeah, sure.
- 11:40There's these metrics and popularity.
- 11:43They, there's like all over the map.
- 11:44So one of the thoughts I had though, is the people that use Flask, this is not a knock against Flask.
- 11:49I like it.
- 11:50But one of the, my sort of impressions is if I just need to, like you said, just create a couple APIs and just, we're just going to get something going real small and simple.
- 11:57And it's just roll.
- 11:58Like those people are not as invested in the ecosystem and the framework as I feel like the Django folks are.
- 12:06I feel like the Django folks, it's a more encompassing part of their development.
- 12:10Like Django feels more part of the project when people adopt it and love it.
- 12:17I don't know.
- 12:18What do you guys think about that?
- 12:18You need a dozen apps to use Flask.
- 12:21And I hope that we get David Lord on to talk about Flask because he's at Django Cons.
- 12:24I mean, it's not a competition.
- 12:25I don't mean to say there's a competition between the two, but there are different purposes, I would say, Carlton, right?
- 12:30Yeah.
- 12:31The different styles as well.
- 12:32Like, you know, if you want to put together something, why not Flask?
- 12:35But I mean, I've been using Django for so long now that even if I just need to spin up two endpoints, it's much quicker for me to do that in Django than it is to go and get a supposedly micro framework and work out how am I supposed to use this?
- 12:48We can put the link in the notes.
- 12:49I made up a repo with the code because you didn't provide code.
- 12:53You can have a single file Django project the same way you can for Flask because a lot of times that whole little world comparison will lead people to assume that Flask is much less complicated than Django.
- 13:04And it's a little bit less.
- 13:05It's more around to how it's structured, which is the point of Carlton's talk.
- 13:08Yeah. So the talk was called How to Use Django as a Micro Framework or something like that.
- 13:12And it was about the base HTTP handlers, the kind of that real core of the framework.
- 13:17And I put up a few examples from different frameworks, like Flask and an old example and Starlet, the async micro framework from Tom Christie.
- 13:26And then I showed how you might put that together in Django.
- 13:30Yeah. For people who don't necessarily live and breathe the web stuff like the three of us do.
- 13:34Yeah.
- 13:34Give them a quick definition of micro framework before you go on.
- 13:37Well, in the talk, I was like, you know, what is a micro framework?
- 13:40Yeah. I'm asking you because I don't want to put my foot out there.
- 13:42The answer I came up with was it's got a great hello world, right?
- 13:46Yeah. Okay. Sure.
- 13:47I think the idea is that it's easier to contrast it with like Rails or Django.
- 13:52Rails and Django, they come with the batteries included with everything you need.
- 13:55You know, you've got your ORM or active record.
- 13:58You've got an ORM, you've got database, you've got migrations, all that stuff.
- 14:02Yeah. You've got all those stuff.
- 14:04Whereas your micro framework, you perhaps get the core HTTP handling and that's about it.
- 14:08And then you have to go and find a forms library.
- 14:10Okay. I found a forms library.
- 14:11And then you have to pull in an ORM or a database of that.
- 14:14Okay. I'll use that.
- 14:15And, you know, so there are Node full batteries included frameworks.
- 14:20Like Happy is very good.
- 14:21It's got everything you need.
- 14:22But like the classic Node example is, oh, you know, I get Express and I pull in this thing for passing URLs and that thing.
- 14:29You know, so there's a continuum.
- 14:31But micro frameworks fit more towards that.
- 14:33You know, you put the pieces together yourself.
- 14:35Whereas a batteries included framework like Django, you get not everything but a lot in the box.
- 14:40Right.
- 14:41Right. But your experience is more Django pieces, Django building blocks than a little flask, a little SQLAlchemy, a little this, a little that.
- 14:47Definitely. And I've been doing it so long now that I'd struggle to break out of that.
- 14:52I just, you know, I throw in a bit of Starlette or a bit of FastAPI, see what's going on with the new frameworks.
- 14:57Every new framework that comes out, I'll always give it a run.
- 14:59And then my question is, okay, well, what can we learn from that?
- 15:02This portion of Talk Python To Me is brought to you by Square.
- 15:07Do you run or want to build a web application that sells products or services?
- 15:11Building a successful online business is the stuff that dreams are made of.
- 15:14But accepting payments and handling credit cards with all the various regulations is a common stumbling block.
- 15:20But not with Square's payment API.
- 15:22With Square, your Python web app can easily take payments.
- 15:25You'll seamlessly be able to accept debit and credit cards as well as Square gift cards.
- 15:29Let your users pay with their digital wallets.
- 15:32Square works with Apple Pay, Google Pay, and MasterPass all in one go.
- 15:36Your API includes PCI compliance, end-to-end encryption, dispute management, and fraud detection.
- 15:42Build your online payment form in three steps with Square payment SDKs.
- 15:46Step one, create a new Square API application.
- 15:49Step two, add Square's payment form to your checkout flow.
- 15:52Step three, use Square's API to charge the card.
- 15:55So get started building your business on Square.
- 15:57Just visit talkpython.fm/square or click the link in your podcast player's show notes.
- 16:02That's talkpython.fm/square.
- 16:06A really large site.
- 16:08If you ask them what language and framework do you use, it's like everything.
- 16:11Just because of the needs of a massive site, it ends up being...
- 16:15It's hard to say that it's truly one thing.
- 16:16I mean, Instagram still has pieces of Django in it.
- 16:19But at that scale, it's its own thing.
- 16:21And I think the micro frameworks are really good for doing that.
- 16:24This might be a pessimistic take, but I've heard people make that a micro framework allows you to switch the complexity from individual developers who may be sharing you just as much up to your upper level because they only can touch a tiny part of the monolith.
- 16:38So they can, in a way, do less damage.
- 16:40That's actually an organizational argument for micro frameworks is that only the software architects or the senior people fit it all together.
- 16:46They weave the pieces or they build the puzzle or whatever.
- 16:49That, I guess, especially if you're testing suite isn't as good as it could be.
- 16:52Yeah.
- 16:53I don't know.
- 16:53I think there's an interesting conversation about like monolith type software styles versus not.
- 16:58I'm actually a big fan of the monolith style.
- 17:00All my attempts to break it into little pieces, at least in the microservices, which is not the same as micro framework, but I always feel like I've quadrupled my deployment complexity to half my software complexity.
- 17:11And I'd rather manage half as much software complexity as twice as much deployment complexity.
- 17:16Like if you were part of a five person team in a large organization assigned to fix something and you're just like, there's no way we can get done within this monolith.
- 17:23But like, oh, we could spin something up and solve the problem and move on.
- 17:27I play that by a lot.
- 17:28I think, you know, or an individual project, you get fancy and you customize Django or you use a third party package that is out of date or maybe you shouldn't use any of the same issue.
- 17:38Yeah, I don't know.
- 17:38Like, OK, we're segwaying slightly back into the deployment topic, which ostensibly we came to talk about.
- 17:44But I think the thing with microservices, right?
- 17:47So if you've got a massive corporation, you can't have all the things going on in one team.
- 17:52So you need to segment it somehow.
- 17:54And then you can define service boundaries and it starts to make sense.
- 17:57Then all the tech blogs become about microservices and how this is the way.
- 18:02And then learners come along and they're like, well, I've got to build my thing using microservices.
- 18:06It's like, no, that's really not a good move.
- 18:09But where are the blog posts?
- 18:11Not for, you know, and now the pendulum swings back.
- 18:14And, you know, there are lots of posts now about how monoliths are making return and how they're the way to go.
- 18:20And so hopefully the beginners come and see those posts.
- 18:22But when you're learning and everyone's saying, oh, you must use a microservice architecture.
- 18:27It's like, hang on.
- 18:28Yeah, because the people who are knowledgeable are writing about their day job.
- 18:31They're not writing about spinning up a Django app on a weekend, which is possible.
- 18:35And you can deploy it, too, which we could.
- 18:37Should we get into that deployment?
- 18:39I do want to just point out, I think this might be the article that I read before.
- 18:43Like the, yeah, you're not Google.
- 18:45You're not LinkedIn.
- 18:46You're not Facebook.
- 18:46You're not Netflix.
- 18:48There are people who actually that's an inaccurate statement about.
- 18:51There's plenty of people that work at those companies.
- 18:53But like you said, Carlton, the people who come along, they see these companies who they respect and say they must be doing it right.
- 19:00And so often with these deployment stories, with these design patterns, you know, should you have like separate caching servers that run like something like Redis?
- 19:09Yes, you should.
- 19:09No, you shouldn't.
- 19:10And that's the right answer at the same time.
- 19:12But with the context that you need, right?
- 19:14Are you trying to run 10,000 servers and let 500 people work on this project?
- 19:19Or are you two people trying to do a startup?
- 19:21Like those are not the same tradeoffs and balances you want to make, right?
- 19:25Yeah.
- 19:25And it depends as well on your model.
- 19:27So one example that I really like is Stack Overflow.
- 19:29Now they're built entirely on the Microsoft stack.
- 19:32So they've got SQL Server and they're using .NET.
- 19:34But the basic point is they've got a really big database one and then, you know, a few worker processes in front of those.
- 19:41And that's it.
- 19:42It's a classic monolith.
- 19:44And they're one of the biggest sites on the internet.
- 19:46And yet they're incredibly fast.
- 19:47Yeah, exactly.
- 19:48As fast as you could ever want.
- 19:49Okay.
- 19:50They do it in this kind of monolith, old school style, you know, vertical scale.
- 19:55Make it just bigger.
- 19:55Don't spin out parallels.
- 19:57Just make the thing bigger.
- 19:59Buy a bigger database server.
- 20:01So that's, you're not going to be bigger than Stack Overflow, right?
- 20:04Right.
- 20:04And then another example we have.
- 20:05And when you are, you'll reevaluate it anyway.
- 20:07Whatever you do now is not going to solve that problem.
- 20:09Yeah.
- 20:10But you're not going to be bigger than Stack Overflow.
- 20:11And then we had another example, which was Dr. On Demand.
- 20:14They came on, Matt Layman from Dr. On Demand came on Django Chat recently.
- 20:17They've got a more containerized approach to it.
- 20:21But the thing is, they're doing peer-to-peer communication between, you know, many simultaneous peer-to-peer video communications.
- 20:28Because Dr. On Demand is like a telemedicine, right?
- 20:30Right, right.
- 20:31Like, I need to book a video appointment with my doctor.
- 20:35Yeah, exactly.
- 20:35And so, but they've got so many of those processes needed to be spun up that they need something which scales out and then back down again very easily.
- 20:44So they've got a kind of more, like, modern, more, a cooler technology.
- 20:48They're not as big as Stack Overflow probably in terms of raw traffic.
- 20:51But they need that flexibility of architecture.
- 20:53That's what we always think about, right?
- 20:54We say, it depends.
- 20:55That's our timeline.
- 20:56Yeah, it depends.
- 20:57It depends.
- 20:57Yeah.
- 20:58Exactly.
- 20:59That's your subtitle.
- 21:00I do think the context, right?
- 21:02When people talk about design patterns, deployment, architecture, those are always within a silent, not mentioned most of the time context in which that makes sense.
- 21:12And you've got to decide, are you in that context or are you not?
- 21:14Yeah, no, entirely.
- 21:15I should say, what problems are you trying to solve?
- 21:16Like, you can't innovate everywhere.
- 21:18Like, there's so many pieces to a website.
- 21:20Do you want to innovate on deployment?
- 21:22Not until you're, you know, Instagram, I don't think.
- 21:24No, well, I think that's a great point.
- 21:26And it's when you're small, the most important thing is adding features and going quick, right?
- 21:31When you get bigger, the most important thing is to not go down, right?
- 21:34If random little project that is like an ordering service for a restaurant in Milwaukee, if it goes down for half an hour, it's not ideal, but it's not the end of the world.
- 21:45If Google goes down for half an hour, people really notice.
- 21:48You know, it's like front page news type.
- 21:49So it's just a totally different thing.
- 21:51Now, before we move on to more deployment stuff, and we're kind of in there, I do, before we get away too far, maybe we could touch real quickly on some of the new features that are coming in 3.2 and like the Django 3 stuff that you guys are excited about.
- 22:03Yeah, maybe can you start with just 3 in general, Carlton?
- 22:06Because I think that makes 3.2 have more context.
- 22:08Well, okay.
- 22:09So, but 3 introduced, 3 began the process for making Django async, right?
- 22:14So we added, so historically, Python has this WSGI, the web service gateway interface.
- 22:20So Django is a WSGI framework.
- 22:21Flask is a WSGI framework.
- 22:23It was this standard so that application servers could talk to protocol servers, which could talk to the internet without, you know, each framework having to have its own protocol server.
- 22:32So Gunicorn is a WSGI server, and it can speak to Flask, and it can speak to Django, and it can speak to any other WSGI server.
- 22:39Right.
- 22:39You can use that, and I can use uWSGI, and it's, we don't have to coordinate or do anything.
- 22:45It just happens.
- 22:46That's because of the WSGI or WSGI thing, right?
- 22:49Yeah.
- 22:49So that's the standard.
- 22:50And so in order to make things async, there's this thing called ASCII, which is the asynchronous gateway interface.
- 22:57I don't know.
- 22:58Yeah, I don't know.
- 22:58I don't really, yeah.
- 22:59Anyway, it's not WSGI, it's ASCII.
- 23:01So first of all, Django 3.0 brought in an ASCII handler.
- 23:05So it wasn't async at all, but you could run it under an ASGI server.
- 23:09And then 3.1 brought in actual async views.
- 23:12And you can define an async def view, and you can use, I don't know, HTTPX, which is like an asynchronous HTTP client with a request.
- 23:21Yeah, it's like requests, but async.
- 23:23Right.
- 23:23Or what's the ORM story?
- 23:25Does that support async at await yet?
- 23:27Right.
- 23:27No.
- 23:27So that's not there yet.
- 23:29So this is something that will develop probably over the course of the Django 4 lifestyle.
- 23:33So there's plans and there's thoughts.
- 23:36And we need to get to the point where you, with the ORM, where you can, down to your kind of filter call.
- 23:43And so things like filter, they can be totally synchronous because they don't actually do any IO.
- 23:47They don't actually hit the database.
- 23:49But when you then go, right, I've got my query set and I'm going to iterate it and I'm going to fetch the objects from the database.
- 23:55We need that bit.
- 23:56Even if the actual connection is run in a thread or whatever, we need that bit to be fully async.
- 24:01And then Django will feel async as it is.
- 24:05At the moment, if you write an async for you in Django, you kind of have to say, well, I'm not going to touch the DB.
- 24:09I'm not going to.
- 24:10Yeah.
- 24:11You can wrap the ORM in async to async wrapper, but you kind of lose the point of that.
- 24:17Yeah.
- 24:17Yeah.
- 24:17But that's coming, right?
- 24:18Yeah.
- 24:18So Andrew, yeah.
- 24:19So Andrew Godwin, who's driving this effort, he gave a talk at DjangoCon Europe about the structuring of this and what it's going to look like.
- 24:27And it's like, yeah, that makes sense.
- 24:29This is going to work.
- 24:29And we don't have to get, what's nice is we don't have to get async all the way down to the very bottom because we can run the actual, we can sort of hand off the actual database connection in a thread executor.
- 24:40But from the outside of the ORM, it will look async.
- 24:43And then you can, you know, you can stream out your content records of maximum throughput as you want to, that kind of thing.
- 24:50Yeah.
- 24:50Well, the fact that you can already do external APIs.
- 24:53And if you're going down the microservice path, you can do your microservice calls with HTTPX and await those.
- 24:58That's already a huge step.
- 24:59Yeah.
- 24:59Yeah.
- 25:00So without, and this works, what's amazing about the way Andrew is just absolute hero, but he put it together in such a way that you can run this with a WSGI service.
- 25:10You're running Django 3.1 with Gunicorn.
- 25:13Like you always have.
- 25:14Yeah.
- 25:14And you think to yourself, I just need to make a couple of API calls, but they're quite slow and I want to make them in parallel.
- 25:19You can do that just by writing an async def call and then, you know, making the parallel calls using HTTPX.
- 25:26And it just works.
- 25:28And Django does all the rest for you and adapts it.
- 25:30And you didn't have to change your application server.
- 25:32You didn't have to do, you know, it's just like, yeah, we've got async just there.
- 25:35One of the challenges if you're talking to the database is you say, okay, fine.
- 25:39The bottleneck was we are waiting at the web server level, at the Django level.
- 25:44And then we're going to push that down to the database.
- 25:46We're going to just make all that async.
- 25:48All of a sudden, all the pressure is now on the database, which can be a problem.
- 25:52But if you're talking external APIs, you're now pushing the pressure onto the internet, which is way scalable.
- 25:57Yeah.
- 25:57And it's always going to scale more than you, right?
- 26:00You're not going to need that many client requests probably.
- 26:02Yeah.
- 26:03Also, David Smith out there says 3.2 will be a great release.
- 26:06You guys have done a great job getting many patches over.
- 26:08Yeah, for sure.
- 26:09Thank you, David.
- 26:10Super.
- 26:11We were working really hard.
- 26:13We had two longer lists and we got, you know, one we had to bump for Django 4.0, but the rest we got in.
- 26:19So we were very good.
- 26:19Okay, so 3.0, acing it away.
- 26:21This is a big deal.
- 26:22Yeah.
- 26:23And so those are the big features for 3.0.
- 26:25And then what's coming in 3.2, we've got various other bits and bobs.
- 26:29You can customize primary keys.
- 26:31So traditionally, they've just been autofield, which is in 32.
- 26:34Well, eventually, you know, if you get 22 billion of those or something, you can run out.
- 26:38So you can now customize that for big in.
- 26:41And over the next couple of releases, you know, major releases, we will make the default big in because that's probably what it should be in 64.
- 26:48Because then you're never going to run out of primary keys.
- 26:50But that's something that big sites run into that, especially if you start creating, I don't know, events, an event log.
- 26:57Yeah.
- 26:57You know, a site can generate a lot of events and they can add up quickly.
- 27:01You know, so.
- 27:02Yeah, they definitely can.
- 27:03Functional indexes in the ORM.
- 27:05So you can create an index on an expression like that these were greater than or that the sum of this was.
- 27:11And then you can query on those at full speed because they're indexed.
- 27:15That's a really big feature.
- 27:16Oh, really?
- 27:17So you can do a query like the sum of the orders of this.
- 27:20The customer is greater than $100.
- 27:22Yeah.
- 27:22And that's a relationship.
- 27:23Yeah.
- 27:23And then you can create an index on that value.
- 27:25And you've been able to do that in raw SQL for, you know, any amount of time.
- 27:29But that's now exposed at the ORM level.
- 27:32And that's nice.
- 27:33That's awesome.
- 27:33You can just kind of.
- 27:34Yeah.
- 27:34For people who are doing reporting or that kind of thing.
- 27:37Yeah.
- 27:37That's massive.
- 27:38This portion of Talk Python To Me is sponsored by Linode.
- 27:43Simplify your infrastructure and cut your cloud bills in half with Linode's Linux virtual machines.
- 27:48Develop, deploy, and scale your modern applications faster and easier.
- 27:52Whether you're developing a personal project or managing large workloads, you deserve simple, affordable, and accessible cloud computing solutions.
- 28:00As listeners of Talk Python To Me, you'll get a $100 free credit.
- 28:03You can find all the details at talkpython.fm/Linode.
- 28:08Linode has data centers around the world with the same simple and consistent pricing regardless of location.
- 28:13Just choose the data center that's nearest to your users.
- 28:16You'll also receive 24-7, 365 human support with no tiers or handoffs regardless of your plan size.
- 28:23You can choose shared and dedicated compute instances,
- 28:26or you can use your $100 in credit on S3 compatible object storage,
- 28:30managed Kubernetes clusters, and more.
- 28:33If it runs on Linux, it runs on Linode.
- 28:36Visit talkpython.fm/Linode or click the link in your show notes,
- 28:40then click that create free account button to get started.
- 28:45And then we've got, I don't know, a new memcache backend for the cache.
- 28:48We've got, you know, updating the API for using the admin for nice decorator API for creating various admin customizations.
- 28:56We've got themes in the admin.
- 28:57We're going to ship a dark thing.
- 28:59It's a big one for people to see right away.
- 29:01Because the Django admin could use a refresh and there's been all sorts of third-party ways to customize it,
- 29:07but now be built in a bit more.
- 29:08There's all sorts.
- 29:09In the blog post for the author, I described it as a mess of new features.
- 29:13And that's exactly what it is.
- 29:14But what's nice is it's not, there aren't, apart from async, which is coming,
- 29:18there aren't any new major features in Django, right?
- 29:21It's 15 years old.
- 29:22It's rich and mature and largely feature complete.
- 29:25But each major release, each eight months, it always amazes me when we're drawing to get up the final release notes,
- 29:32how much depth and extra, like, substance there is in the features that we've managed to add
- 29:38and that have been contributed over that eight-month period.
- 29:40Yeah, that's fantastic.
- 29:41So I feel like you're capturing much of the modern Python awesomeness.
- 29:45One other area that's, I think, interesting.
- 29:48I have no idea what your plans are around it,
- 29:50but maybe you could just give us your thoughts, is type hints, type annotations.
- 29:54Yep.
- 29:54That's difficult for us.
- 29:57Carl, about that a little bit.
- 29:58Yeah, I mean, that's difficult for us because Django, I mean, if you take the awesomeness,
- 30:02it's super dynamic.
- 30:03And there's an amazing project, django-stubs, where they've got stub files and they've got,
- 30:08you know, they've done a super job.
- 30:09And it really does work well.
- 30:11So if you load up VS Code or PyCharm these days,
- 30:14you get very good autocomplete around things like Django model field definitions.
- 30:19Yeah.
- 30:19And that's all powered by django-stubs.
- 30:22Yeah.
- 30:23Which probably is powered by type hints underneath, right?
- 30:25Yeah, yeah.
- 30:26It totally is.
- 30:26A year or so ago, there was some discussion about whether we would make those inline hints
- 30:30in Django itself.
- 30:31And the technical board at the time said, no,
- 30:33we need the typing technology to evolve a little bit further in Python itself before Django can
- 30:39jump on and say, look, we endorse this particular technology.
- 30:42There is, there's various ways of doing it and various type hinting, type checkers and various.
- 30:47And so, so we, we favored mypy, which is obviously the endorsed one.
- 30:51Well, what about the others?
- 30:52We can't support them all and they might change and-
- 30:55Pyright and all the different various initiatives.
- 30:57Yeah.
- 30:57We can't take it out once it's in.
- 30:59The thing with, the reason why people love Django is because it's super stable.
- 31:02You know, you write a site five years later, you don't really have to do very much to keep
- 31:06it going.
- 31:06And so the technical board at the time said, no, we're not going to bring those type hints
- 31:11into Django, but that will be reviewed.
- 31:13You know, we'll look at it again in a little while's time.
- 31:16One thing I will say about typing in all the peps, it says type hints remain optional.
- 31:21They're not meant to be compulsory, even by convention.
- 31:23Do you feel maintaining Django a certain pressure to have them?
- 31:27I do worry that that optionality of type hints is perhaps undermined a little bit in the day
- 31:33to day development.
- 31:34I'm not sure.
- 31:35I also code in Swift, right?
- 31:37Which is a fully statically typed.
- 31:38Swift is pretty strong in its syntax.
- 31:41Like you can't even null out.
- 31:42Yeah.
- 31:43Even if they could be, right?
- 31:44If there's not allowed to be optional, explicit, there's a lot of interesting stuff happening
- 31:48in the Swift type.
- 31:49Yeah.
- 31:49I mean, Swift is a fantastic language, but there's no option.
- 31:52It's type hints or it's type annotations all the way.
- 31:56And then when I come back to Python after a few hours of that, I'm like, oh, this is so
- 31:59breath of fresh air.
- 32:00You know, the thing that I really, the comparison that I make a lot is between TypeScript, which
- 32:05is type annotations for JavaScript and Python type hints.
- 32:09And I always walk away from TypeScript feeling like, ah, that was way harder than it should
- 32:14have been.
- 32:14Why was it so frustrating and fighting me?
- 32:16Whereas in Python, you might get some squigglies because you didn't quite define something just
- 32:20right or it wasn't defined at all.
- 32:22But then it just, it carries on, right?
- 32:23Whereas things that are completely, it must work within this context.
- 32:28They can become challenging, especially the reason I bring up TypeScript is the stuff that
- 32:33it brings in is not necessarily typed, just like Python.
- 32:35Whereas Swift is end to end.
- 32:37It's all from scratch under that same system.
- 32:39So it's coherent.
- 32:40But bringing in, say, jQuery into TypeScript, like there's no TypeScript jQuery.
- 32:44I know there's like stubs you can put on and whatnot, but like that kind of stuff is more
- 32:48Python-like.
- 32:49And so I think it's pretty interesting.
- 32:51Yeah.
- 32:51And Django's in that very much in that boat where it was never written with type hints in
- 32:55mind.
- 32:55Yeah, of course they didn't exist.
- 32:57And if you look at Django stubs, it's awesome.
- 32:59But a lot of the things are like string or any.
- 33:02And it's like, that's horrible, right?
- 33:04You don't want to write that every single time.
- 33:07That's an issue.
- 33:07And then another thing I see, which I'm not sure about, sometimes they make a type like
- 33:11a model, the Django model admin, they make it a generic that takes the model type, which
- 33:16tells you what it's the admin of.
- 33:18And I remember, and I look at that and I wince a little bit.
- 33:20You're like back to C++ templates or something, right?
- 33:23Yeah, yeah, yeah.
- 33:23And I see where they're going with that.
- 33:25It's amazing what they've been able to do there.
- 33:27But I remember coding Objective-C UI Table View, say.
- 33:30And what you would always do is you get object, your row class in from the UI Table View delegate
- 33:36where you're getting a list of cells, right?
- 33:37So like a list of email messages.
- 33:39And you'd immediately cast it to the type you wanted so that you knew what you were dealing
- 33:43with.
- 33:44Yeah.
- 33:44In a way, when I get something back from a model admin, I'm quite happy to write colon
- 33:48model name.
- 33:49Yeah.
- 33:50To tell the editor what it's meant to be.
- 33:52To tell the type checker what it's meant to be.
- 33:54And then for the rest of the method, I get the autocomplete.
- 33:57I get the type checking.
- 33:58And you probably don't put any more type hints because it's just now flows.
- 34:01And it's, I agree.
- 34:02It's so good at generating, like allowing you to generate code incredibly fast if the tool
- 34:06supports it.
- 34:07One quick comment or thought that before we move on, this having types around the ORM
- 34:13is really interesting because all the big ORMs seem to do the same basic flow.
- 34:17You know, I'm thinking, you know, Django ORM, SQLAlchemy, even NoSQL ones like MongoEngine,
- 34:22which I use.
- 34:23They all have a class which has the columns defined as descriptors.
- 34:27So at definition time, they create the tables or the collections.
- 34:31And then at runtime, they become the scalar versions of the thing they say they are, right?
- 34:36That an integer column is now actually an integer.
- 34:38So what I've done when I define the model class is say like name colon str equals string
- 34:45column.
- 34:45And so the Python thinks it's all the types are actually what I said, the primary types like
- 34:51in the model.
- 34:51And then the underlying ORM can do what it needs to do.
- 34:55But, you know, the rest of my code is like, oh, that's a float column right there or float
- 34:59field.
- 35:00That's been really helpful.
- 35:01I don't know.
- 35:01I haven't run into any problems doing that, but it's been pretty helpful.
- 35:05Yeah.
- 35:05I mean, it's the thing that brings my talk.
- 35:07Well, there's data classes, right?
- 35:09Which they brought in in 3.7 or 3.8.
- 35:11Yeah.
- 35:11And then Pydantic is an exciting thing, which is...
- 35:14Pydantic is fantastic.
- 35:15Yeah.
- 35:16You define a model, call it a model with exactly this.
- 35:19It's like field name type with an annotation string or int or whatever.
- 35:24And that works really well.
- 35:26And I can imagine us generating Django ORM models from that kind of thing.
- 35:31But then you end up needing options.
- 35:33Like, is it nullable?
- 35:35Or is it, you know, is it required?
- 35:37Is it...
- 35:38What validators does this field have?
- 35:39And then it starts...
- 35:41When you start to add validation, it starts to look almost like what we've got now.
- 35:45I mean, Pydantic's got one good advantage in raw serialization speed.
- 35:48It's very fast.
- 35:49So that's something we can learn.
- 35:51But the short answer is, I don't know.
- 35:53But it's exciting times, isn't it?
- 35:54It's very exciting times.
- 35:55All right.
- 35:56Let's talk really quickly about maintaining your content or things that you generate.
- 36:01Like, you guys all write articles, books, do online stuff, even podcasts.
- 36:06So 3.2 is out.
- 36:08What broke?
- 36:08Like, real quickly, Will, maybe you want to just talk about what you've been doing to...
- 36:12Yeah, there's a reason why there's very up-to-date Django books, because the release cycle of every
- 36:18nine months doesn't overlap with the traditional publisher cycle.
- 36:22So for me, I mean, I'm on version, I think, five for most of the books.
- 36:26So I was on 110 or 111.
- 36:28So it's sort of like writing the book again.
- 36:31Every time I basically go through from scratch, because all the code is linked to the text.
- 36:36Because I'm self-published, I can do all that.
- 36:38I have my flow down.
- 36:39So really, I have a list of new features I know that are in there.
- 36:43So I'll play around with them to make sure that things don't break.
- 36:45And then I'm constantly emailing with readers.
- 36:48So I have feedback on what works and what doesn't.
- 36:51So half the new features are fixing things so it's smooth.
- 36:54And then half just making the text.
- 36:56So at this point, I feel pretty good about the flow of all three.
- 37:00And people will say, what about this?
- 37:01And maybe I can explain it a little bit better.
- 37:03I added, I mean, so for a 3.1 added in the beginner's book, I really wanted to have proper
- 37:08deployments, but not go as deep as I do in the professional's book.
- 37:12So I did introduce environment variables and showed, I think, a pretty elegant way to get
- 37:17environment variables and to have some lockdown for deployed site.
- 37:21Whereas before in beginners, it was just sort of like the local version, which is pretty open,
- 37:26was what you deployed because it was more about getting something up.
- 37:29I was able to introduce environment variables.
- 37:31We could talk about that more.
- 37:32There's a third party package.
- 37:34It's great.
- 37:34So that's always the tension for me is showing and telling, right?
- 37:37Like I want to explain everything, but I don't want to overwhelm people.
- 37:40And so that's part of the thing I have to think about for 3.1.
- 37:43And I think also for Django being so stable, at least you can say all the stuff is still
- 37:48the same.
- 37:49There's just new features we haven't mentioned or a new way maybe is better, but as opposed
- 37:53to this does not work anymore.
- 37:54Well, it's the difference between what trips the professional programmer and someone who's
- 37:58new.
- 37:58So for example, in 3.1, the pathlib was added when you create a new Django project, the settings.py
- 38:05file, which is the default settings.
- 38:07The way the routes are done is a little bit different.
- 38:09Like a minute stack overflow thing for someone who's used to using Django.
- 38:13or the breaking stuff, but that can completely derail a beginner.
- 38:16There's usually a couple of things like that.
- 38:18You know, so in that case, like I have a dedicated blog post because I knew that was coming.
- 38:22And just this morning, I got more questions around it.
- 38:24So it's that's sort of the thing that fun me is figuring out how do I, you know, be compassionate
- 38:29to the true beginners, but we're more further along.
- 38:34It's a lot of work to do.
- 38:35I don't know how you could do it.
- 38:36I don't either.
- 38:36I was just dealing with some GitHub issues on some folks who are having trouble because a
- 38:41mismatch of pip upgrades and other packages.
- 38:44And it's just like, it's just how it goes.
- 38:46Real quick, John from the live stream is really excited about the admin themes.
- 38:51So that's really cool that that is going to come along.
- 38:53Thanks, Sean.
- 38:54They add up to greatness.
- 38:55I think that's, I love that.
- 38:57Yeah, that's a great, great say.
- 38:58All right.
- 38:59We talked a lot about deployment already, which is why I've been dancing around a bit.
- 39:02But let's go ahead and talk about deployment.
- 39:04So when I create a web application with Django or really honestly with Flask or anything, I've
- 39:10got a cool app.
- 39:11But it's, you know, web apps are not generally meant for the individual.
- 39:15They are meant to go on the internet and be amazing and connect things and allow other people
- 39:19to do stuff.
- 39:20And that's a huge gap, right?
- 39:22So maybe I've just learned how to do Django.
- 39:23You just talked about your beginner's book, Will, and I finally got that one page that
- 39:28wouldn't show.
- 39:29And the database stopped, you know, crashing when I did that one query because I checked
- 39:32for none now and it's all good.
- 39:34Wait, I have to learn Linux and I have to become an admin and what the heck just happened, right?
- 39:38So how do you guys approach that?
- 39:41What do you tell that person?
- 39:42Yeah.
- 39:43First of all, hand on shoulder, I feel you because it's just there's this massive deployment
- 39:52gap.
- 39:52We've got the Django tutorial.
- 39:54We've got the Django girls tutorial.
- 39:55We've got the Django rest framework tutorial.
- 39:57People have done those.
- 39:58They've got their app together.
- 39:59They've come up with some ideas.
- 40:00They've learned a teeny bit of JavaScript to make it that bit better.
- 40:03And now put it online.
- 40:04And exactly this, I've got to learn Linux.
- 40:06Oh my word.
- 40:08Yeah.
- 40:08Among other things.
- 40:09I mean, it's two things though, right?
- 40:10I think, I think like when I think about this, oh, there's, there's two ways to think
- 40:14about it.
- 40:14One is making it friendly, which we can talk about.
- 40:17And then there's the specifics of, do I, you know, do I do it on a VPS?
- 40:21Do I do it on a pass?
- 40:23So there's two separate things.
- 40:24The first one, I think we can generalize and Django has some good notes on that.
- 40:29The second one is sort of a deep end of opinion.
- 40:32I guess I'm in favor of like, I use, I'm a big fan of platforms.
- 40:36If somebody had something that like hosted AWS for Django, I would use that.
- 40:40I mean, so, and I'm just going to throw it in here now.
- 40:43I'm working on a app for this exact problem.
- 40:45It's called button.
- 40:47It's btn.dev.
- 40:48And it's the idea is to be able to spin up a small environment for this exact.
- 40:55I just want to get my app on line use case without, you know, you're having to become
- 40:59a sysadmin expert.
- 41:00Yeah. So the spectrum looks like to me pass, right?
- 41:04Platform as a service, which you said you like Heroku and there's other options as well.
- 41:08Yeah. Heroku, DigitalOcean.
- 41:11Then I think maybe button is even before that.
- 41:14I'm not entirely sure.
- 41:14Like in terms of complexity.
- 41:16Let me jump in.
- 41:16You've got the platform as a service.
- 41:18You've got Heroku, which is there at one end.
- 41:19And that's kind of like, they'll run your app, but they don't, that's it.
- 41:23Right. Or, you know, you can run another worker instance, but then you say to yourself,
- 41:27I want to, I just want to put a file online.
- 41:29And it's like, well, how on earth do I do that?
- 41:30I can't. Or I want to put up a static website.
- 41:32So I've got to bring in, I know, Netlify because another service.
- 41:36Yeah. Netlify is really nice for just pure static sites.
- 41:39Actually.
- 41:40Yeah.
- 41:40It is. It's awesome.
- 41:41But then all of a sudden you're running two services and then you want to do some log analysis.
- 41:45So you've got to bring in and it's like, oh, hang on.
- 41:47I've got three services now running and it's, it gets a bit out of hand.
- 41:51So then on the other hand, you've got AWS and you go to AWS and it's like, oh my word.
- 41:56You know, it's the paradox of choice.
- 41:58It's just like that in Azure.
- 41:59I mean, they're both incredibly powerful, but it's just like, oh my goodness.
- 42:03Look at this admin dashboard.
- 42:04Like I, there's huge thing with a 50 choices.
- 42:07I go into one and it expands into 20 and then I need to figure out the right one of those 20.
- 42:11It's just, it's mind boggling.
- 42:12Yeah, exactly.
- 42:13And so where button fits in that is it's on AWS, but it provides a very simplified environment.
- 42:19This is because it's part tool.
- 42:20It's a tool to do it, but also a guide that says, look, this is how you should deploy.
- 42:24So the app puts together the environment for how you should deploy your Django app or, you
- 42:29know, you can do any app, but you know, I begin with Django because that's where obviously
- 42:34what I know.
- 42:34And then the difference between, well, why wouldn't I, why would I use that instead of
- 42:39a platform as a service like Heroku?
- 42:40Well, because if you go out of it, it's just AWS.
- 42:44And so you can go on and move on to other things and you can export to.
- 42:47When you do go closer to now you are kind of Google or whatever.
- 42:51You've got a growth path.
- 42:53Obviously not, not far down that road, but a little ways you can go, oh, we actually need
- 42:57to do this other thing.
- 42:58Yeah.
- 42:58And so that's what I'm aiming for.
- 42:59And that that's launching very soon.
- 43:01It'd be early access by the middle of February.
- 43:03You know, beta by end of the quarter.
- 43:06And then what I call version, what ends the beach?
- 43:09I don't know.
- 43:09End of the year, I would imagine.
- 43:10Yeah.
- 43:11Yeah.
- 43:11That sounds really cool.
- 43:12We'll definitely link to it in the show notes.
- 43:14When I was pausing there, I said, okay, well, on one end we have pass like Heroku and other
- 43:20platform as a service options.
- 43:21What is the other end?
- 43:22Is the other end Linux virtual machines or is the other end Kubernetes clusters?
- 43:28It's Kubernetes cluster.
- 43:29It's well beyond virtual machines, right?
- 43:31So like to spin up a virtual machine is not a problem.
- 43:35The problem is that you get a bare OS and then you've got to do all the app to get installed
- 43:40to turn it into something you can deploy on.
- 43:43Right.
- 43:43And then you do that once.
- 43:45And then the second problem is that six months later you need to upgrade it and you've got
- 43:48to replace that VM.
- 43:50So that's very difficult.
- 43:51And I think that's what leads people into this kind of world of containers.
- 43:55And then into containers, it's like, oh, well, I've got, I need an orchestration platform
- 43:59to, ah, and that's, there are people who make a career doing that.
- 44:04Yeah.
- 44:05You can't expect to do that sensibly.
- 44:06I agree with Carlton.
- 44:07It depends slightly in that, like, so in my professionals book, we, I show how to use Docker
- 44:11and Docker is for a smaller site.
- 44:14I think actually you can put your containers online so you can, in a lot of different flow
- 44:19is actually quite nice.
- 44:21But I agree with Carlton's broader point about, you know, that is and all the rest.
- 44:24It's, I feel like is the goal.
- 44:26I'm setting up a Kubernetes cluster and I'm running the data layer and I'm running the caching
- 44:30layer.
- 44:30And I'm, if you're managing that whole thing in a cluster, you're at the far right end
- 44:35of the most complicated.
- 44:37But if I'm going to deploy to a hosted Kubernetes container and consume a database as a service
- 44:42and a caching tier as a service, then it starts to fall back to, well, I just get my
- 44:46container to run and plug in these connection strings and we're good to go.
- 44:49I think there's, it can kind of live on both sides, honestly.
- 44:52There's different approaches and different sweet spots for each individual.
- 44:55The difference for me is you can containerize your application and run it up, but where do
- 45:00you container that to?
- 45:01Where do you run that container?
- 45:02Is that on a set of VMs, which you provisioned yourself and put a container management system
- 45:07on like Kubernetes?
- 45:07Or is that on somebody else?
- 45:10Like, is it basically service, the Cloud Run?
- 45:12Cloud Run takes your container and runs it and you don't know anything about where it's
- 45:17running.
- 45:17So that's more like a platform as a service again.
- 45:20Yeah, it is.
- 45:21It falls back in that.
- 45:22So Will said he's a fan of Heroku.
- 45:24Carlton, let me ask you this question.
- 45:25If you were writing an application in Django that was expected to get 5 million data-driven,
- 45:31like proper requests, not for CSS and whatnot, but proper requests a month, how would you deploy
- 45:36it right now?
- 45:37I would deploy it on a pretty big VM with as many process workers as I need.
- 45:43So I'd put stick Nginx as my front end.
- 45:45Perhaps I'd probably use something like application load balance in front of it, one of these things
- 45:50that AWS will provide or Azure have got their equivalent load balancer.
- 45:53Then I'd have my Nginx, which is serving my static files.
- 45:56Behind that, I'd probably have two, three.
- 45:58It's also doing SSL, for example, right?
- 46:00Your Let's Encrypt bits.
- 46:01Yeah.
- 46:02Yeah, yeah.
- 46:02And they're handing all certificate renewals and all of that kind of thing, which is probably
- 46:06worth the money because it only takes you a few minutes.
- 46:08But you forget and then your site goes down and no, just hand all that stuff off.
- 46:12So I'd put that on a nice size VM.
- 46:15I'd have, you know, three, four, five Gunicorn workers serving the application instances,
- 46:19load balanced behind Nginx.
- 46:22And then I'd have Postgres on a decent size RDS, which is a managed database service behind
- 46:28it.
- 46:28As a first preference, I would scale up the VM and I would scale up the RDS rather than-
- 46:34Way before you scale out.
- 46:35Yeah, way before I scale out.
- 46:37Yeah, I agree.
- 46:38Like if you can, as soon as you have them scaled out, it gets tricky, right?
- 46:41You become, it takes you up a notch in that DevOps story.
- 46:44At that point, you're hiring, you know, an extra hand just to manage the ops, an extra
- 46:48hand to manage the ops.
- 46:49Yeah.
- 46:50It's like, well, what was the revenue of the application that justified that the salary and
- 46:54the social security of that extra hand?
- 46:55Yeah.
- 46:56I mean, maybe you're like, well, I don't really want to pay for that larger VM that's $80 a
- 47:00month instead of $10 a month.
- 47:02But if the alternative is now we spend human hours on making, you know, three $10 VMs run,
- 47:08you know, it's so easy for businesses to become Pennywise pound foolish around these kinds
- 47:12of things, right?
- 47:13It's just like, oh, we can't get you a new monitor, a new keyboard.
- 47:16Like, really?
- 47:17You pay me like $80,000 a year and you won't give me a new keyboard to be more productive?
- 47:21Or I feel like that's the deployment equivalent of that.
- 47:24Yeah.
- 47:24No, it's penny pinching for no reason.
- 47:26I mean, the other great example is Sentry, right?
- 47:28So Sentry is your kind of, you log all your errors to it, send your exceptions to it.
- 47:33It gives you great stack traces and it links it back to GitHub.
- 47:35It's awesome.
- 47:35Why would you not have this?
- 47:37And then you're on the free account, you know, it'd give you 5,000 events a month or something.
- 47:41And it's like, oh, we need 30 bucks to get onto the, like the million events a month.
- 47:45The manager's like, no, you can't have paid Sentry.
- 47:47You're like, what?
- 47:48What are you talking about?
- 47:49So then you stop logging.
- 47:51You're like, well, we can't log that event because of Sentry.
- 47:53And then you're blind.
- 47:55And then your app goes down and you spend four hours trying to work out what it is while you're losing business.
- 48:00Like, that was 30 bucks a month for Sentry.
- 48:02Just pay it.
- 48:03But I think it depends if your manager has felt that pay as an individual contributor themselves, right?
- 48:08Because if they haven't, then yeah, stop complaining, developer, you know?
- 48:12But yeah, you should, I always thought, I mean, at Quizlet, which is now like half of all high school students,
- 48:17we had a joint, which I hope they're still around.
- 48:19They're a hosting company, but we were having scaling issues.
- 48:21They came in and we had the whole team CTO, which was great.
- 48:24And, you know, at the end of the day, they were just like, you need bigger hardware, you know?
- 48:28Get more hardware.
- 48:29If you can get more, you know, and as a business person, if you can throw money at a scaling problem,
- 48:34like, yeah, that's the easiest money you've spent.
- 48:37Yeah.
- 48:37You know, so what I'm doing right now, Carlton, is I'm running Nginx on Ubuntu, but I'm using uWSGI.
- 48:44And I came across this, although as I'm starting to think about the ASGI stuff,
- 48:50Gunicorn, Gunicorn, and like uvicorn worker processes is starting to look like a really awesome thing.
- 48:56But what I wanted to point out is there's this great article by the Bloomberg tech folks
- 49:00talking about configuring uWSGI for production.
- 49:04And man, do they have a bunch of good little tips of like, well, here's all these things,
- 49:07but oh, did you know if you turn on like enable threads versus not, or if you set single interpreter
- 49:13mode to true, you automatically get better performance because it was configured to potentially run
- 49:18like Python 3.7 and 3.8 at the same time.
- 49:20And you're never going to do that in one process, most likely.
- 49:23And there's just all these really fantastic settings and like vacuum and whatnot to clean up sockets and whatnot.
- 49:30So people, if they're running uWSGI in production, they should absolutely check that out.
- 49:34That's a really, I read it a bunch of the way I was doing things after reading that one.
- 49:38Just scroll to the image at the top, if you would please, Michael, because a little diagram that I had.
- 49:41Yeah.
- 49:41But like, yeah, so that looks almost exactly how I deploy.
- 49:44Like Nginx in front of a worker process, you know, that's running your Python applications
- 49:49and, you know, talking to your database.
- 49:51Yeah, exactly.
- 49:52It's, it's pretty standard.
- 49:53Yeah.
- 49:53They got memcached in there.
- 49:54So I'd, I'd have Redis instead of memcached, but same deal.
- 49:57Yeah.
- 49:57There's a comment about, does EC2 sit between a VPS and Kubernetes?
- 50:01Yeah.
- 50:02Since you're AWS expert.
- 50:04Okay.
- 50:05Well, I don't know about expert, but so, but on AWS, like you, this is what I haven't found in AWS.
- 50:10Like I would love to love their light sale product, but it just seems totally uncared where they,
- 50:15they kind of manage the cluster all for you.
- 50:17But on the, the, I can't even remember what the cluster services called, but the,
- 50:20you have to provision the EC2 instances and you can do it quite easy.
- 50:24It's not hard to do, but you have to spin those up and they're kind of your responsibility.
- 50:28And then it will run the cluster service on top of it.
- 50:32The Kubernetes on top of it.
- 50:33And then you deploy your containers in there.
- 50:35This is where something like Cloud Run is a bit easier because you don't have that layer of I'm
- 50:40provisioning the underlying instances myself.
- 50:42And you have to choose the size of them and you can scale them up easily enough, but you
- 50:47know it's, it's, it's non-trivial to set up a cluster on AWS.
- 50:50Yeah.
- 50:51That's always been my feeling as well.
- 50:52I also feel like you're sort of committed to their hosted services.
- 50:56And if for some reason you don't want to use them, the step is not a tiny bit more.
- 51:00It's a bigger, a much bigger step to like try to rework that.
- 51:03Yeah.
- 51:03The example is run, you can run your own Postgres on EC2 instances when, you know, you can provision
- 51:09the disks and you can do all that rather than RDS.
- 51:13And for me, I'm like, okay, if you've got a very specialist use case, then yeah, do that.
- 51:17But RDS is great.
- 51:18Just use RDS.
- 51:19Just use the hosted service because again, you're saving money and yet it's a bit more expensive
- 51:24hour, but not as expensive as you, your time, your life force.
- 51:28Yeah.
- 51:28Well, I think also it depends, right?
- 51:30Are you one single person who is building up an idea and you have zero revenue and you're
- 51:37just trying to do this for two hours a week to see if you can get a little tiny bit of traction.
- 51:41Maybe it is worth an extra five hours, right?
- 51:43Versus I have actual money coming in the door and I'm trading out building this feature or
- 51:48that feature.
- 51:48Like those are really very different contexts.
- 51:51Also though, you get yourself a Raspberry Pi and you can install Nginx on it and Postgres
- 51:56on it.
- 51:56And no, but you can run all those, right?
- 51:58And you can do it locally and you can bet you can run a Apache bench again against it and
- 52:03you, it will serve plenty.
- 52:04So you can get not the nano one, but yeah, sure.
- 52:08But you can get, you can run Postgres is my point.
- 52:11You don't need RDS to run a small Postgres, but if you're running a slightly bigger one, then
- 52:17yeah, use RDS.
- 52:18And then if you're a specialist and you really need to customize your Postgres somehow,
- 52:23then okay.
- 52:23Yeah.
- 52:24You know, spin up the EC2, install Postgres on it and customize it to your heart's content.
- 52:27But that's well beyond my skill level.
- 52:30And yeah.
- 52:30This is why they have hundreds or thousands of employees, right?
- 52:33Like when people say, why do the big companies do that?
- 52:36It's like, well, why does Instagram have a thousand, whatever thousand engineers when Carlton,
- 52:40you and I could spin up a, you know, a prototype relatively quickly.
- 52:44It's like, because we're not dealing with the traffic they are.
- 52:47And so it just gets exponentially harder, which is why you need a lot of people for all these
- 52:52issues.
- 52:52Absolutely.
- 52:53Will, you mentioned something really interesting there that I would like to just touch on for
- 52:57a moment.
- 52:58Then we're getting short on time.
- 52:59You said you could run SQLite.
- 53:01Oh, well, so that Carlton has a good story about SQLite.
- 53:04I mean, about how it's, so generally people say, well, you can't use it.
- 53:07You shouldn't use it at all.
- 53:09But there are some cases where that's not the case.
- 53:11I mean, if it's a read heavy application, you can probably get away with it.
- 53:14Simon Willison's doing a lot with data set.
- 53:16Yeah.
- 53:17I just had him on the show.
- 53:18His episode just came out this week, actually.
- 53:20Yeah.
- 53:21He's great.
- 53:21And that is such a cool project.
- 53:23I feel like that is actually an undersold story for the beginners, right?
- 53:28Because deployment of web application often means deployment of web application plus database
- 53:34server, plus backups of database server, plus like all of a sudden it goes from, you know,
- 53:4020% to 90% hard or whatever, right?
- 53:42Or you go to hosted and you're like, okay, well, I still got to backup that thing potentially.
- 53:46And, you know, there's just, you've got potential migrations.
- 53:49I don't know.
- 53:50There's a lot of stuff going on.
- 53:51And if you can say, well, until you actually get much traffic, you can just say, here's
- 53:55the DB file and the SQLite connection on the one machine that I have.
- 53:59And you back up that file every now and then, that might be a good story.
- 54:02If the alternative is it's too much for me to get my app out.
- 54:05Yeah, yeah.
- 54:05No, definitely.
- 54:06Especially if it's a blog or a content site, like a shop catalog where it's all read only
- 54:11and, you know, maybe you're using the admin to manage the content on it.
- 54:14If it's only one person using the admin, you're not going to have concurrent rights, which
- 54:18is the thing about SQLite.
- 54:20And so it's never going to be an issue.
- 54:22And it is fast.
- 54:23It's fast.
- 54:24Read only workloads.
- 54:26It's fast.
- 54:26It's fast enough.
- 54:27It's yeah, it's very fast.
- 54:28Yeah, you can use it.
- 54:29And there's no server for people who don't understand are not totally aware.
- 54:32Like it comes with Python and it runs in process.
- 54:35There's no other server to set up and connect to.
- 54:37Yeah.
- 54:38So Carlton correct me on that at one point, because I was saying, oh yeah, no SQLite.
- 54:42And he was, so I have to give credit to Carlton for there are some instances.
- 54:45Here's the secret about SQLite.
- 54:49It's got a writer headlock.
- 54:50A WAL mode, which means that actually you've got a good chance of being able to do kind
- 54:57of concurrent rights to Django's ORM has got a retry value, which if you set that, you know,
- 55:02you know, a little bit higher.
- 55:03If it gets database locked, it will try again in a second.
- 55:07And then, you know, you can go quite a long way enabling these things.
- 55:10And then when you finally in production actually get a database was locked error, then you could
- 55:16think, you know what?
- 55:16I think it's time we move to post.
- 55:18Yeah.
- 55:18In my world, I'm running MongoDB as the database.
- 55:21And it doesn't make sense to consider running that on SQLite.
- 55:24But I can remember back when I first started deployment, like, okay, well, I got to learn Linux.
- 55:28I got to learn NGINX.
- 55:29I got to learn uWSGI.
- 55:30Like, okay, what other deployment?
- 55:32Like, how do I have to learn running my database on these things?
- 55:35There's just, there was a lot.
- 55:36And I can definitely see if you could say, well, here's an intermediate step to get it
- 55:40out and get it going.
- 55:41And then you just change the connection string at some point over to a big separate server.
- 55:45I think that's a really good path.
- 55:47It's a little bit like, you know, raw SQL versus Django models.
- 55:51This is timely because I've had a thread emailing with a reader who doesn't quite, has something
- 55:56in mind.
- 55:56And he's like, I modeled it all out, the scheme all out in SQL.
- 55:59And SQL is easy to learn the basics and really hard at scale.
- 56:03And while Django lets you write SQL, you really, really, really should resist doing that unless
- 56:09you're a way better programmer than I am.
- 56:11So whereas before you would have to learn tons of stuff, the same thing with deployment,
- 56:16you can get a lot of the way there by trusting someone who says, until you need it, don't
- 56:21bother.
- 56:21The same thing with database stuff.
- 56:23Like, okay, you know, do some basic SQL, understand a little bit of the relations, but that's the
- 56:27power of the Django ORM is that it will handle so much of this for you.
- 56:30And if you think you need to go custom, unless, you know, if you have any doubts, you shouldn't
- 56:34do it.
- 56:34Yeah.
- 56:35And the migration side, that's a huge part of a challenge if you were maintaining it yourself.
- 56:39Yeah.
- 56:40Yeah.
- 56:40I mean, I was, you know, Andrew, Andrew was responsible for the, doing most of the, a lot
- 56:45of the async stuff now.
- 56:46Nice.
- 56:46All right, guys, we're getting short on time, but I do want to just really quickly cover
- 56:49one more thing.
- 56:50Servers up and running, feels like it works.
- 56:52I watched it all day.
- 56:53It was fine.
- 56:54I want to walk away from my desk.
- 56:56I want to know that it's probably still fine.
- 57:00And to me, like Carlton, you already talked about one thing.
- 57:03There's some really great monitoring services that you integrate at the API level.
- 57:06Like you plug in as a library to your code.
- 57:09Sentry being one of them.
- 57:10They're really great.
- 57:11They sponsored the show for a while.
- 57:12Thanks for that as well.
- 57:13But I use Sentry on.
- 57:15Yeah, they're great.
- 57:15And I, I've got Sentry running on my apps and every now and then I'll get an email.
- 57:19And a lot of, at this point, when I first integrated that type of service, I got a lot of, oh, I
- 57:24didn't know that was happening.
- 57:25Oh crap.
- 57:26I'm going to have to fix that.
- 57:27Well, that's why there's a lot of logging and stuff, right?
- 57:29Yeah.
- 57:29Yeah, absolutely.
- 57:30And once I kind of dialed in now, it's more like, well, somebody tried to send like some
- 57:34binary hacky thing that broke the URL parsing, but it's not really a problem.
- 57:39It's just right.
- 57:39But having that thing there is, is really important.
- 57:43I think.
- 57:43Yes, absolutely.
- 57:44Absolutely.
- 57:45Sentry.
- 57:46I, I just can't see a reason not to use it.
- 57:48Even if they've got the free plan.
- 57:49Why wouldn't you have that?
- 57:51Yeah.
- 57:51The free tier, like once you run out, you can decide whether or not you want to pay for it.
- 57:54But, you know, at least get, get us some kind of insight into the errors that are happening.
- 57:59Yeah.
- 57:59The other thing that I'm a fan of is Prometheus.
- 58:01It takes a teeny bit of setting up, but again, you can get yourself a Raspberry Pi and you
- 58:05can play with that locally.
- 58:06And it's not that hard.
- 58:07You can put it on your Mac or you put it on your Windows machine.
- 58:09It will run, but get a Raspberry Pi, set it up, monitor the device.
- 58:13Prometheus is good fun.
- 58:15There's a dashboard that goes with it called Grafana.
- 58:17And then they do a log thing called Loki, which, you know, you have to configure it yourself,
- 58:21but it teaches you about your application.
- 58:23You have to say, okay, I want to monitor this.
- 58:25And then you can put a little couple of tags in and then, okay, you get metrics then for
- 58:30that bit.
- 58:30So, you know, perhaps you've got a slow view.
- 58:32So one thing you can do is you can put on your Nginx logs, you can log the upstream response
- 58:38time.
- 58:39So you've handed off to Gunicorn or to uWSGI and Nginx will then log how long those responses
- 58:44took.
- 58:44And then you can say, well, actually that those responses to that particular request is taking
- 58:48a long time.
- 58:48And then on that request, you can go into that view and you can add a little, you know,
- 58:52a little bit of instrumentation and then you can start getting metrics for what that view
- 58:56is doing.
- 58:57And yeah, yeah.
- 58:58You know, that's really good.
- 58:59He does over all of you guys.
- 59:00Yeah.
- 59:00I'm also a fan of Datadog.
- 59:02I think those sound pretty similar.
- 59:03Okay.
- 59:04I think they're Boston based actually, but yeah, they do.
- 59:06They call it APM application process monitoring.
- 59:09And so there's quite a lot of commercial solutions.
- 59:11And then Prometheus is the sort of DIY.
- 59:14Nice.
- 59:14Equivalent.
- 59:15Okay, cool.
- 59:16So that's the errors and performance.
- 59:18The other side is just the website is down, right?
- 59:22So maybe there's so many different layers and moving parts.
- 59:25For example, like we have very little downtime with our train courses and stuff.
- 59:29But one thing that did happen is we have this thing that will take the main IP address and
- 59:33switch it to a failover server so we can do reboots and patches and then it'll switch it
- 59:38back.
- 59:38And that's all done through an API through like a git push.
- 59:41And then it all just sort of goes down the chain.
- 59:43Well, at one point there was a bug where that switch of the IP like disassociated it with either
- 59:49server.
- 59:50So the server thought it was fine.
- 59:51It's like, well, things are chill, right?
- 59:53Right.
- 59:53So you log in and it's like, yeah, no problem.
- 59:55But the site was just timing out or so.
- 59:57I don't remember what happened,
- 59:58but it wasn't good.
- 59:59So I think there's some really nice uptime monitoring things that are free that people
- 1:00:04should just plug in to go hit these three pages just to see.
- 1:00:07I can talk to the site.
- 1:00:08It talks to the database and the answer comes back.
- 1:00:10Yeah, for sure.
- 1:00:10I mean, I've got those configured.
- 1:00:11I was I know we're almost out of time.
- 1:00:13I did want to mention on deployment.
- 1:00:14I think one thing that trips people up, especially around Django is static files, which is something
- 1:00:18if you're doing it, you know, VPS, you know, and I think the key thing is that
- 1:00:23your server doesn't want to run your static files like it can ways to do it.
- 1:00:28But, you know, so both within Django, Django out of the box defaults to local settings.
- 1:00:32And the Django has a local server.
- 1:00:34They'll just run your static files to put that into point and deployment.
- 1:00:38You would run collect static, which is a command that makes a single static file.
- 1:00:42And you probably want to use something like white noise.
- 1:00:44But there's a couple of steps there.
- 1:00:45But something that really sort of intermediate level Django people, it really trips them up.
- 1:00:49I have a blog post on that because I forget the commands.
- 1:00:52There's like four things to tweak.
- 1:00:53You just have to do every time.
- 1:00:55It works locally.
- 1:00:56Why doesn't it work live?
- 1:00:57And it's like partly because people don't understand, you know, how their server is working because
- 1:01:01they don't have to.
- 1:01:02But, you know, that's I just want to.
- 1:01:04Yeah.
- 1:01:05Awesome.
- 1:01:05Yeah.
- 1:01:06One of the big four.
- 1:01:07Right.
- 1:01:07So get your code in place.
- 1:01:08However you do that.
- 1:01:09Tab or get pulled.
- 1:01:10You know, whatever.
- 1:01:11How do you get it there?
- 1:01:12Configure your virtual environment.
- 1:01:13You know, so in pip installed all your requirements.
- 1:01:15Configure your database and make sure you connect to that and get your static files in place.
- 1:01:19Database is the other one that, you know, well, you know, this might go like beginners.
- 1:01:23They're like, well, I updated it locally and I pushed my code.
- 1:01:26Why isn't my production database different?
- 1:01:28Right.
- 1:01:29And it is like I still occasionally make that mistake, you know, just but, you know, your code
- 1:01:34is not your two separate databases.
- 1:01:36Yeah, absolutely.
- 1:01:37That's what you want as well.
- 1:01:38You want to be able to write your blog post in locally and then it appear on your server.
- 1:01:43You don't want to have to go, oh, no, now I have to paste it into the admin on my remote.
- 1:01:46Yeah, it depends how automated you want to go.
- 1:01:48I mean, for a simple like so my learn Django site, which is basically one admin, largely
- 1:01:53a content site.
- 1:01:54I mean, in terms of easy peasy, it's just Django and I've got Cloudflare in front and it's done.
- 1:02:00It's super fast.
- 1:02:01I get, you know, decent amount of traffic.
- 1:02:04I don't have to think about it.
- 1:02:05I've got I think I've got PagerDuty, one of those, you know.
- 1:02:07Yeah.
- 1:02:08Yeah, that's the one that tells you if it's completely unreachable, right?
- 1:02:12Yeah, yeah.
- 1:02:12But it's an external one that, you know, exactly to your point, because you can't always trust
- 1:02:17yourself.
- 1:02:17Yeah.
- 1:02:17Yeah.
- 1:02:18There's some interesting ones.
- 1:02:19I use StatusCake and it's neat.
- 1:02:21But there's some one that I heard the Dan Bader was telling me about that would sound a lot
- 1:02:25nicer, but I'm like, but this one's already set up.
- 1:02:26You know, it's not that important.
- 1:02:29I get I get notifications.
- 1:02:30If it goes down, I'm all good.
- 1:02:31It's plumbing, right?
- 1:02:32Like, I'm happy to live.
- 1:02:33We have the new silver pipes.
- 1:02:35Like, yeah, my bronze pipes.
- 1:02:36Fine.
- 1:02:37I'm just gonna leave it.
- 1:02:37Well, that's Docker for Carltons, you know, so.
- 1:02:39I use Docker loads.
- 1:02:41All right, guys.
- 1:02:43Yeah.
- 1:02:44No, all the time.
- 1:02:45All the time.
- 1:02:45Let's just wrap it up really quick.
- 1:02:46There's a Django newsletter.
- 1:02:47I learned about that.
- 1:02:48That's interesting.
- 1:02:49You guys want to just mention that that exists?
- 1:02:50Yeah.
- 1:02:51Yeah.
- 1:02:51So that's something I run with Jeff Triplett, who's a partner at RevSys.
- 1:02:54He's a Python board member, very involved with Django.
- 1:02:56So django-news.com.
- 1:02:58There wasn't a regular Django newsletter.
- 1:03:01There wasn't a podcast.
- 1:03:02So he and I have been doing that for a little over a year and has projects, articles.
- 1:03:06I sort of wish someone else did it, so I didn't have to do it.
- 1:03:08But we got a lot of people using it.
- 1:03:11So that's a good resource for the community.
- 1:03:13Yeah, fantastic.
- 1:03:13All right.
- 1:03:14So before I let you two out of here, final two questions really quick.
- 1:03:17Will, I'll go with you first.
- 1:03:19Notable PyPI package out there that you were like, oh my gosh, I ran across this the other
- 1:03:23day.
- 1:03:23I can't believe it.
- 1:03:24That's a good question.
- 1:03:25I'll go back to an old school one, which I think is Bleach, because I've been thinking
- 1:03:30about a course on forms.
- 1:03:31And Bleach is a Python one, not Django-specific, but you pretty much always want to have that
- 1:03:36added.
- 1:03:37So this validates user input to make sure there's no cross-site scripting type stuff?
- 1:03:41Yeah.
- 1:03:42So that's top of mind.
- 1:03:44Not a new one, but I think along with white noise, you just got to use it.
- 1:03:48Yeah.
- 1:03:48Awesome.
- 1:03:48Carlton?
- 1:03:49Yeah.
- 1:03:49No.
- 1:03:49Well, the one that's just really captured my imagination
- 1:03:52recently is Rich, which is the-
- 1:03:54Yeah, Rich is cool.
- 1:03:55the library for creating basically nice terminal output, nice console output, but it does
- 1:04:01everything.
- 1:04:01It even has like tables and all sorts of stuff.
- 1:04:04Yeah.
- 1:04:04Yeah.
- 1:04:04It's really neat.
- 1:04:05But like, it's got this inspect functionality where you can get an old, and you're sitting
- 1:04:09there and you're in this shell and you're like, I want to see it.
- 1:04:12And you print it and you deer it and you look at the dict and it's all, it's not, and then
- 1:04:16you go inspect, and Rich formats this thing where it's like, oh yeah, I can look here and
- 1:04:21I can see exactly what's going on.
- 1:04:23And it's just amazing.
- 1:04:24Rich is brilliant.
- 1:04:25And 20,000.
- 1:04:25That's what I love about coding, right?
- 1:04:27I'd never heard of this before and it's clearly a very established thing.
- 1:04:31Well, I think it's last year.
- 1:04:33It's taken off quite, yeah, it's about a year old.
- 1:04:35It's taken off quite steeply in its adoption.
- 1:04:37One that I ran across really recently, just throw it out there because it's a Django semi-related
- 1:04:42one, is Disk Cache.
- 1:04:43Have you guys heard of that?
- 1:04:44No.
- 1:04:44So it's a really interesting caching plugin that will, instead of using memory for caching,
- 1:04:50it will store it onto local disk because you usually have way more hard drive space than
- 1:04:54you have memory in the cloud.
- 1:04:55And it plugs into Django to like a stand in for the cache there.
- 1:04:59Okay, fine.
- 1:05:00Yeah.
- 1:05:00I mean, I'm a big fan of file cache in general because like memory is expensive, right?
- 1:05:05So memory cache is the best way and Redis and Memcache are good ways of doing that all
- 1:05:10in memory.
- 1:05:10But then you think, I just want to generate some HTML once and then just pipe it off the
- 1:05:15hard disk.
- 1:05:15Exactly.
- 1:05:15To me, this is kind of the equivalent of SQLite versus a real database.
- 1:05:19It's like, you don't need Redis or Memcache or something like completely set up just like
- 1:05:23until it gets beyond whatever.
- 1:05:25It looks pretty interesting.
- 1:05:26You do these packages things, by the way.
- 1:05:27Like we include packages every week in Django News and there's also like an awesome Django
- 1:05:31repo that Jeff and I do.
- 1:05:33You know, because the problem is you want some degree of curation, right?
- 1:05:36Like something new.
- 1:05:37That's right.
- 1:05:37Like legit enough to be worth looking at.
- 1:05:39Yeah, absolutely.
- 1:05:40Thanks.
- 1:05:40Yeah, that's very cool.
- 1:05:41All right.
- 1:05:42And then final question.
- 1:05:43If you're going to write some Python code, what editor do you use?
- 1:05:45VS Code.
- 1:05:46Same for both of us.
- 1:05:47Yeah.
- 1:05:48Right, Carlton?
- 1:05:48You're still in the other code?
- 1:05:49Well, I have to.
- 1:05:50Yes.
- 1:05:51VS Code.
- 1:05:52Very nice.
- 1:05:53Use it a lot.
- 1:05:53Also, though, I still like BBEdit.
- 1:05:55Yeah, right on.
- 1:05:56All right.
- 1:05:56Keeping it old school every now and then just for a little nostalgia.
- 1:05:59I'll tell you what, right?
- 1:06:00So I'm using VS Code and I'm like, but I need to do some transformations or I need to,
- 1:06:05you know, do a multi-file search and a diff here.
- 1:06:07And VS Code's got all that stuff, but it's a bit, you know, this is built in JavaScript,
- 1:06:11whereas BBEdit's a native Mac app and it's got a lot going.
- 1:06:13Yeah, absolutely.
- 1:06:14I use PyCharm.
- 1:06:15Yeah, I'm a big fan.
- 1:06:17Local company here in Portland, Panic, came out with, what's it called?
- 1:06:20Nova?
- 1:06:21I think it's Nova.
- 1:06:22They just came out with a brand new editor.
- 1:06:23Yeah, yeah, yeah.
- 1:06:23I want to give that a go.
- 1:06:23It looks pretty interesting as well, yeah.
- 1:06:25It looks just beautiful.
- 1:06:27Transmit.
- 1:06:27I love Transmit.
- 1:06:28Yeah.
- 1:06:29I use it all the time.
- 1:06:30All the time.
- 1:06:31For S3 stuff.
- 1:06:32We were talking about Nova, yeah.
- 1:06:33Fantastic.
- 1:06:33Cool.
- 1:06:33All right, gentlemen.
- 1:06:35Thank you so much for being on the show.
- 1:06:36Thank you for having us.
- 1:06:38Yeah, it's been great.
- 1:06:39And thanks for all the work on Django and I'll catch up with you all soon.
- 1:06:42All right.
- 1:06:42Thanks for having us.
- 1:06:43This has been another episode of Talk Python To Me.
- 1:06:47Our guests on this episode were Will Vincent and Carlton Gibson, and it's been brought to
- 1:06:51you by Square and Linode.
- 1:06:53With Square, your web app can easily take payments, seamlessly accept debit and credit cards, as
- 1:06:58well as digital wallet payments.
- 1:07:00Get started building your own online payment form in three steps with Square's Python SDK
- 1:07:05at talkpython.fm/Square.
- 1:07:09Simplify your infrastructure and cut your cloud bills in half with Linode's Linux virtual machines.
- 1:07:13Develop, deploy, and scale your modern applications faster and easier.
- 1:07:17Visit talkpython.fm/Linode and click the Create Free Account button to get started.
- 1:07:22Want to level up your Python?
- 1:07:24We have one of the largest catalogs of Python video courses over at Talk Python.
- 1:07:28Our content ranges from true beginners to deeply advanced topics like memory and async.
- 1:07:33And best of all, there's not a subscription in sight.
- 1:07:35Check it out for yourself at training.talkpython.fm.
- 1:07:38Be sure to subscribe to the show, open your favorite podcast app, and search for Python.
- 1:07:43We should be right at the top.
- 1:07:45You can also find the iTunes feed at /itunes, the Google Play feed at /play, and the
- 1:07:50direct RSS feed at /rss on talkpython.fm.
- 1:07:54We're live streaming most of our recordings these days.
- 1:07:57If you want to be part of the show and have your comments featured on the air, be sure to
- 1:08:01subscribe to our YouTube channel at talkpython.fm/youtube.
- 1:08:06This is your host, Michael Kennedy.
- 1:08:07Thanks so much for listening.
- 1:08:08I really appreciate it.
- 1:08:09Now get out there and write some Python code.
- 1:08:11We'll be right back.