Monitor performance issues & errors in your code

#428: Django Trends in 2023 Transcript

Recorded on Wednesday, Jul 26, 2023.

00:00 Have you heard of Django? It's this little web framework that, well, kicked off much of Python's significance in the web space back in 2005. And that makes Django officially an adult. That's right, Django is now 18. And Django continues to lead the way on how community should be done for individual projects, such as web frameworks. We have Carlton Gibson and William Vincent back on the show this episode to discuss a bit of Django history, Django trends in 2023, a little bit of HTMX and Django, and lots more. This is Talk Python to Me, episode 428, recorded July 26th, 2023.

00:36 Welcome to Talk Python to Me, a weekly podcast on Python. This is your host, Michael Kennedy.

00:54 Follow me on Mastodon where I'm @mkennedy and follow the podcast using @talkpython, both on fosstodon.org.

01:01 Be careful with impersonating accounts on other instances, there are many.

01:05 Keep up with the show and listen to over seven years of past episodes at talkpython.fm.

01:10 We've started streaming most of our episodes live on YouTube.

01:14 Subscribe to our YouTube channel over at talkpython.fm/youtube to get notified about upcoming shows and be part of that episode.

01:22 This episode is brought to you by Sentry and us over at Talk Python Training.

01:27 Please check out what we're both offering during our segments.

01:29 It really helps support the show.

01:32 Will Carlton, welcome to Talk Python Me.

01:34 It's awesome to have you both back on the show.

01:37 Thank you for having us on again, Mike.

01:38 Yes, thank you.

01:39 It's always fun.

01:40 Yeah, it's always fun to have other podcasters on the show.

01:43 We'll talk a bit about your podcast in a moment.

01:45 Maybe just do a quick introduction.

01:47 I know people probably know you from your show Django Chat.

01:49 if you know you're from being on Talk Python To Me previously, but for those who don't.

01:53 Will, you wanna go first?

01:54 - Sure, so William Vincent, I have three books on Django, most notably Django for Beginners.

01:59 I run a site, learndjango.com.

02:01 I just got off three years being on the board of Django, so Django's run by a non-profit.

02:05 Run a weekly newsletter on Django, Django News.

02:08 Too many things.

02:10 So yeah, most of my time is spent doing some consulting and a lot of teaching and learning about Django, so I'm very happy to be at that stage.

02:16 - It's a good combination, right?

02:17 - If you can make it work, it is.

02:18 - Yeah, you need that sort of cycle of, you know, I need to learn too and be interested.

02:22 - Yes.

02:22 - I like learning and teaching, so.

02:24 - One of the challenges that I think people can fall into and the traps is if you just teach, it's hard to have that, it looks like a good idea, but let me tell you, it's a bad idea and here's the three reasons and here are the tears that I've shed because I tried this this way.

02:39 - You need a little hands-on, like for me, it's running all the infrastructure and APIs and mobile app stuff at Talk Python, which is plenty to get the tears.

02:47 I pulled out plenty of hair, but you know, like I think consulting plus teaching is a really common mix for that.

02:53 You like it?

02:54 - Yeah, I do.

02:55 I mean, so I've been working on, so I have this site, learndjango.com, that I'm trying to consolidate everything onto that site.

03:00 And so that's been an effort I've been working on in earnest the last couple of months.

03:04 And so it's actually been really fun to just be an engineer for a change.

03:07 And I kind of wish I could find a me to help me when I get stuck, but there is no being, as Carlton will share something, you know, being stuck is part of the game, But it's uniquely satisfying and frustrating to code because everything is solvable, but still I find things that stop me for a couple of days and I'm just like, it brings me back to the first couple of months of coding and the terror of like, I'm not smart enough, I can't do this.

03:32 But I know that I'll get it done, and I do get it done.

03:34 So you get the yin and yang, but it's uniquely satisfying to do the commit and it's done.

03:40 Whereas even a podcast, it's in the bank, but it's not quite the same binary feeling of accomplishment.

03:46 - That's true.

03:47 The getting stuck is frustrating, but also it means you're about to level up, right?

03:51 You're gonna figure out something, yeah.

03:53 - I try to be excited about it, 'cause I know if I'm stuck, then lots of other people are gonna be stuck.

03:56 Or a lot of times I'm stuck on one little thing, and it's really 'cause there's some other thing, some fundamental that I didn't know as well as I thought I did.

04:03 So we can talk about that, but I have thoughts on all of that.

04:06 So yeah, it's a nice mix to do.

04:08 And more importantly, now I have friends and peers when I get stuck, I can ask them. So Carlton, of course, is one of them, you know, Django, former Django fellow, a couple others, it's important to, you know, we can talk about this, but when you're learning, learning how to ask a good question on stack overflow, or Django has its own forum, which is a great resource forum, Django project.com, you know, but the next stage is like, I did a walk, I slept on it, like knowing when to ping a friend, because you don't want to ping a friend all the time. But sometimes it's like, okay, like, this is, I'm truly stuck.

04:37 there's no point like wasting a week or two on this.

04:40 Yeah, for sure.

04:40 That's a really nice stage to get to. And it's also helpful to help other people too, because you're thinking about something and someone gives you something they're stuck on, you're like, oh, boom, that's that. And then you're like, hey, I'm working on, you know, something that's stuck. So anyways, having a community is really, really levels you up to and also people who can relate to good and bad things about code.

04:57 Django is very stable, but has a host of new features, many of which I haven't actually used, Carlton can talk about them. So it's important to, Yeah, have community, right? Not just be in your own room with your computer fighting with it.

05:09 Yeah, yeah.

05:09 Any trouble or good or bad thing you've had, many, many other people have had, you just have to find them.

05:14 Unlike the movie stereotypes, it's way more social, this coding thing.

05:18 It is.

05:19 Indeed, before I let Carlton introduce himself, just a quick comment from the audience to make you feel good a bit from Bishnu says, "The first book I read on Django was William's book." So, thank you.

05:30 Thank you. I appreciate that. Yeah, I just, one last point and then I want Carlton to talk, but I wrote three books, Django for beginners, APIs professionals, that first came out in 2018 and 19.

05:40 And then I've updated all three of them every year since then. So on the one hand, it's been four years, I haven't had a new book, but it's also I've written what? Or you've had 12 new books.

05:49 12 new books.

05:50 Yeah, I mean, I really have. I really have. It's, it doesn't feel quite as satisfying, but I know that I have a built in audience. And I've, so it's a weird dynamic to be in a situation where it's sustainable to maintain and update your stuff. I mean, I'm sure you can relate, you have all these different courses, right? That's the thing that falls off. You do all the effort, you get the course out, and then it goes out of date or it could be made better, but...

06:10 Or Pydantic 2 comes out.

06:11 Django every eight months comes out. Yeah.

06:13 Exactly.

06:14 So it's, yeah, I try to think of the positive of it. It is, I feel like the book is so much better, but a layperson or family members or friends are like, "When's the new book coming out?" It's like, "I just did it." Like, yeah.

06:25 Yeah, indeed. Carlton.

06:27 Who are you, Carlton?

06:27 Welcome. Who are you?

06:28 Who am I? Well, my name is Carlton. I do a podcast with Will. So basically, I've just stepped down as Django Fellow. So I've spent the last five years being a Django Fellow, which means I was contracted by the Django Software Foundation to help maintain Django itself. And they have a couple of fellows, and I was one of them for that period. And I've stepped down in order to go back to building things with Django rather than working kind of just on Django. It's so it's a kind of, you know, after five years, that's, that was a good time period. And it's time for me to go back to building things with Django. I've I've been using Django forever, and I'm a maintainer on a lot of projects in the ecosystem.

07:02 So I've worked on Django REST framework, Django filter, Django crispy form, Django compressor, Django app comp.

07:07 I've maintained the channels package.

07:08 You know, I do quite a lot in that.

07:10 So your code runs on many, many servers, you should say.

07:13 More than I like to think about.

07:16 One thing, when I was a fellow, we were always, people always give us a bit of grief about how conservative Django is.

07:22 It's very stable and we're very cautious about making backwards incompatible changes.

07:27 We try not to do that.

07:28 We've got a solid deprecation policy, got the long-term support policies.

07:32 And then at DjangoCon last year, somebody read out the numbers, the download numbers.

07:37 It's not necessarily the most downloaded package, but it's millions, millions of downloads, millions of projects that are using it, and you really can't break it.

07:47 That's always really humbling and really kind of, yeah, actually, all the work we put into making sure that the product is stable is that's good work. That's important work.

07:56 Yeah, threads is using it, Carlton. You're helping out Mark Zuckerberg.

07:59 Yeah, well, I'll be using a fork of it. We can get into that. But yeah, I was looking at a comment on the forum. I got a little heart from somebody asked on the Django forum.

08:08 Can does Django scale or can I run it on lots of systems? And I'm like, well, you do know that Instagram was built on it. You know, they're still using that call request response cycle. And you know, my comment was, you're not going to serve more traffic than Instagram.

08:21 Yes, Threads is built on that. That core request response bit is still essentially Django.

08:26 Maybe not everyone is up on what Threads is. Not a Parallels programming thing, but a Twitter clone from Meta and Facebook, right?

08:35 Apparently so, yes.

08:36 We have an interview, maybe we can put in the show notes, with Carl Mayer, who was original core Django developer who then went to Instagram. So he spoke for an hour about... So initially it was just, it was pure Django. And then as they scaled, they did things like they they ripped out the ORM and they changed this and that, but there is still a core of it, the request response cycle that's in there.

08:55 That's another interesting thing is Django, when you get to massive, massive size, a lot of companies, you know, they have thousands of engineers, right?

09:01 We have, we Django has just the community.

09:04 So as soon as you hop off the guardrails, then you're kind of on your own.

09:08 And that's sort of separate debate on whether it's worth it or not, but you can get quite large and it's interesting.

09:13 By contrast, like I believe Shopify is still on Rails, believe or seem to have gone much longer. Carlton, yeah, you have something to add?

09:20 Well, I don't think it's really I mean, I know, Instagram moved away from the ORM. But that was quite a long time ago. If you look at octopus and crack, and they're still basically using something that's basically vanilla Django to do, you know, massive projects. And so, you know, what it was back in, you know, 1.6 1.7 1.8, when Instagram were needing to pull away from what Django is, is a lot different for Django is at 2.2334. Now 4.2, I think it's gonna be 5.

09:47 It's gonna be 5.

09:49 I wonder if they regret that.

09:50 I wonder, not necessarily if it was the right choice at the time, but do they kind of wish, like, wish they had access, if nothing else, to fork version 5 instead of version 1.6.

09:59 I wish they'd been a bit more pushback on Django from thinking about, because what was it that caused them to change?

10:07 I think the move from it being able to root string names, strings as view names, like, and having to import the view itself.

10:14 And I think at that point, like for Instagram to rewrite the whole stack, it was too much.

10:19 And in the end, they kind of forked, but it would have been great if we could have kept them on board.

10:23 I think for Instagram, they can, they can, they got enough engineering chops, but it would have been much nicer for Django if we could have kept them on board, I think.

10:31 Well, maybe like a quick positive shout out for the whole meta as a larger organization.

10:36 They seem to be doing a lot for Python these days, you know, - For Python, yes. - They're really working a lot on, you know, Sam Gross' initiative on No GIL and the faster Python and Cinder and, you know, all that probably does come out of some of the foundational stuff for Instagram and running Django there.

10:51 - Yeah, and I think Carlton is still involved in, very much in pushing Python forwards and, you know, what they're trying to do.

10:57 So, you know, all Q-Ducks do them.

10:59 It's very easy to dog on the big corporations so they don't pay enough of it, but it's important to recognize when they do contribute that, yes, actually that's a good thing.

11:07 - Yeah, there's plenty that need dogging on, like a lot.

11:10 - Most.

11:10 - We still have support for Oracle in Django, for example.

11:13 - Interesting.

11:14 - But Carlton, deployment, there's something else you're working on.

11:17 - Well, yes.

11:18 I mean, so I've been, so one thing I wanted to quit or step down as fellow and get to working is my button tool, which is my simple deployment tool.

11:26 So it's quite vanilla.

11:28 It's old school that uses virtual private server.

11:31 It uses Ansible.

11:32 It's all on AWS.

11:34 And then I'm building UI and tooling on front of that.

11:36 slightly delayed because I've had personal issues that have taken me up.

11:40 But, you know, my plan was sit down in April, get on with it.

11:44 My son's been ill for a while. So that's, that's just on the backbone.

11:47 The priority with all of these things is look after yourself.

11:50 And in the situation we've been in, I haven't had time to work on it particularly, but that will be the autumn now.

11:55 And that's, that's kind of, yeah, I've been talking about it for a while, time to actually ship it and have some capacity to ship it.

12:01 But can we, can we do, can we give it a, maybe it's different angle of pitch, which is that so it's built on so deployment is trick. We can talk about this, you know, going from local to production is hard. And when who do you use these days, right? Like there's AWS, there's Azure, there's kind of Google, there still is Heroku, there's new entrance, like fly and some other ones. But what do you really need? Like, if you're a Django, you want someone who knows Django, who just like puts a layer on top of someone that's not going away like AWS. And essentially, as I understand it, button is a Django fellow saying, here's you have a Django app, you want to put it online, let me solve all the hard things, do all the hard work for you. And it's a beautiful UI on something that's not going to change. Yeah, here we go to have it. Because all the it's interesting, I updated my books, I updated away from Heroku to fly for the new update, because Heroku eliminated their free tier. And I personally have really like what fly.io is doing. But it's hard to scale these companies. Like it's not it's non trivial to build what they have. And yet if you're AWS, right, all you're going to do is add, add, add, add features when big enterprise clients want things. And so at some point it becomes unusable for a solo person or a small startup. So I'm a fan of what Carlton is doing.

13:14 Yeah, you want something scary, just go to the AWS console dashboard.

13:18 Yeah, right.

13:19 Exactly. Where do I start? What should I use?

13:22 There should be enough of a thing. I have a Python web app or I have a JavaScript, whatever JavaScript people do, like a, you know, a Rails app. Like, I just want to get it up and have it not break.

13:30 But this came so this the idea for button came out of exactly those those kind of thoughts was Every week on Django chat, we'd have someone come along and deployment would always come up and it would be like some Elaborate story about what they're doing and it's like well, actually if you keep it simple and keep it neat First of all, here's how I deploy and here's how I get my clients to deploy it and this how I deployed many projects over many years and it's continually evolving And then on the other hand when you go to the aws console though, it's like this too much. You don't need 58 services and every configuration option under the button. But it's nice to be able to break out of that, you know, if you do need to scale or you do need to do it.

14:12 So anyway, this is my project. If it wasn't for life circumstances, I'd be slightly further along, but it's going to be the fall now. It's going to be, you know, the shit's coming on nicely.

14:21 And the idea is a simple approach and with a nice UI on top of it that you can use.

14:27 Well, you definitely have our wishes for your son to get well soon.

14:30 So that's rough. Yeah, that's rough when your kid is sick.

14:34 It's been a full on year. It's been a full on year. It's been a full on year. It's been ill over a year now and it's just ongoing. And so, you know, that was another part of why I stepped down as fellow. I needed to take a bit of time just for the family.

14:44 Absolutely. I think back the button for a second. BTN.dev, by the way.

14:49 You can sign up for the mailing list or the alpha is available too.

14:52 Nice.

14:52 I'm constantly trying to push Carlton's stuff because he always downplays everything he's doing. I'm like, come on, man.

14:57 Yeah, but I've got that natural developer shyness.

14:59 I would, I have to wait, I have to polish it and wait till it's perfect.

15:02 And then launch it and then, yeah, and I'm British, I'm nice and reserved.

15:05 And anyway, Michael, you're going to make a question.

15:08 It's exciting.

15:09 And we were just talking about it.

15:11 We were just hyping people up about it.

15:13 How it's cool to have these huge deployments running tons of traffic, doing all sorts of amazing things with like, yeah, we scaled our server.

15:21 So we went from 500 to 300 with this trick.

15:24 Yes, that's a cool thing that pushes the envelope that makes a lot of stuff possible with frameworks like Django and language like Python.

15:31 But on the other hand, most of us are not Instagram, you're not Microsoft, you're not Google, you're not all these.

15:38 And having, or let's say you're not Netflix. I actually think that like what AWS console looks like has a lot to do with how Netflix works probably given how early adopters they were.

15:49 But I just think it's worth emphasizing.

15:52 push button, get it running on a simple server, make it secure, keep it up, you know, zero downtime deploy type stuff, CI/CD, a push to a brand, all those types of things.

16:01 That's more than enough for most people, not just on your hobby projects, but on company business.

16:06 Does your website get a thousand visitors a day?

16:09 It doesn't need five servers with failover and Kubernetes clusters and sharded databases.

16:14 And like, it just doesn't, right?

16:16 And so having that option, something like button, it's pretty cool, I think.

16:19 - Yeah, that's exactly it.

16:20 Like as you speak there, You're just singing to the choir for me.

16:23 It's like, you know, you can get a small box, get a slightly bigger box.

16:27 If you need to get a slightly bigger box than that, you can go get quite an, you can get an awful lot of box for not very much money.

16:32 And then maybe two boxes.

16:35 Yeah, yeah, yeah, exactly.

16:36 But this is the kind of architecture I go for.

16:38 You can scale to a very big site.

16:41 And I know in recent years, Stack Overflow moved to a much more modern and fancy thing.

16:45 But for a long, long, long, long time, they were running on the same kind of big database, couple of front end web servers, a load balancer and nothing more than that.

16:53 And you're not going to serve more traffic than Stack Overflow ever.

16:56 Like nobody, not nobody, but basically nobody's going to serve more traffic than that.

17:00 So that's where I'm coming from.

17:01 And it's not for everybody.

17:03 And there's lots of people who've got opinions, but it's for people who haven't got an opinion.

17:06 It's like, if you don't know, if you don't know how to deploy and you don't really have, if you're not already in the game, then well, this is how I do it.

17:14 And you can choose to do it the same way.

17:16 Or sure.

17:17 I'm really excited about it.

17:18 been talking about it for a long time and not having the capacity to work on it. And now I bar family situation, I have that capacity. And so I'm looking forward to getting out.

17:26 This portion of talk Python to me is brought to you by Sentry. You know that Sentry captures the errors that would otherwise go unnoticed. Of course, they have incredible support for basically any Python framework. They have direct integrations with flask, Django, FastAPI, and even things like AWS Lambda and Celery.

17:47 But did you know they also have native integrations with mobile app frameworks?

17:51 Whether you're building an Android or iOS app or both, you can gain complete visibility into your application's correctness both on the mobile side and server side.

18:02 We just completely rewrote Talk Python's mobile apps for taking our courses, and we massively benefited from having Sentry integration right from the start.

18:11 We use Flutter for our native mobile framework, and with Sentry, it was literally just two lines of code to start capturing errors as soon as they happen.

18:20 Of course, we don't love errors, but we do love making our users happy.

18:24 Solving problems as soon as possible with Sentry on the mobile Flutter code and the Python server-side code together made understanding error reports a breeze.

18:34 So whether you're building Python server-side apps or mobile apps or both, give Sentry a try to get a complete view of your app's correctness.

18:43 Thank you to Sentry for sponsoring the show and helping us ship more reliable mobile apps to all of you.

18:49 - Well, I think it's more broadly, one of the things we're gonna talk about is HTMX.

18:55 And I think there is this, these more iterative tools.

18:58 You know, you don't need to jump to React if you just want a little thing.

19:01 Like you don't need to go Kubernetes.

19:03 - I heard back in, that was done.

19:04 It was just all APIs now, come on.

19:06 - It's all front end.

19:07 I put a toot up the other day that they convinced me otherwise, me, where it's Django is a front-end framework.

19:14 I'm busy writing an application.

19:16 I'm using HTMX, I'm using Alpine, I'm using Tailwind.

19:19 I'm doing it all in Django templates.

19:23 It's like, I'm hardly doing any of the exciting backend stuff that we love Django for.

19:28 It's all front-end, and it's just vanilla Django.

19:31 >> It is.

19:32 >> That's the thing that people who are learning, they're full-stack developer and they're like, APIs, I gotta do it all. And I mean, you must have this, Michael, with people, your students, but I have this a lot of times people who are new say, Oh, I want this and that functionality. And I'm often like, don't go to APIs unless you need to. Because if you're a professional Django developer on a team of more than 10 people, yeah, you're gonna write APIs because they were, there will be front end people who just do front end. But when it's just you, and even if there's not front end, there might be a mobile app. That's our primary case of APIs. Or You might have a public API for users or other companies to work with.

20:06 It doesn't have to be that you're not doing server-side.

20:09 But for a solo person or a small thing, don't just leap to it because it adds so much complexity.

20:15 Do you use Tornado or use an older Python thing?

20:18 Pyramid, okay.

20:19 I've considered switching to something like FastAPI or something like that.

20:23 But then I look and I'm like, you know, it's it's like a real thin layer over just what would be the same anyway.

20:28 And scalability is totally good.

20:31 I mean, it works, it works too.

20:33 It'll run for months without me touching it.

20:34 Like the chances the website go down and it's not my fault because I deployed something is almost zero, like really, really, really close to zero.

20:42 Either that or something's gone wrong in the data center, but like the website itself.

20:46 And so, yeah, I chose that eight years ago and I'm still cruising with it.

20:50 It's great.

20:50 I had a client ask me about HI, HI, sorry, high availability.

20:54 One time they were like, oh, don't we need multiple servers and multiple this and that?

20:58 I'm like, well, how many nines do we need?

21:00 I know, I can't remember the exact number now off the top of my head, but you're already at three nines, even just deploying on the kind of worst setup in the world, because the number of the amount of downtime you'll have will be sub few minutes, because it will be exactly that you deployed something wrong, and then you revert it.

21:15 Yeah, exactly. Oh my gosh, quick.

21:17 But we have, I think people necessarily don't fully appreciate how much really high-end technology for so little money we have accessible to us with these cloud providers.

21:28 We have the best data centers in the world for $10, right? You know what I mean? It's not like, well, these people, like you have the same thing that Netflix is using and for a while they're doing a third of the traffic of the internet.

21:40 Yes, yeah, exactly. So three nines gives you nine hours off a year and you won't even have nine hours off a year.

21:47 Like, yeah, that's highly unlikely. Yeah.

21:49 You know, if something goes down and you don't fix it, but like, it's literally if you deploy, you fix it quickly.

21:55 You get that kind of uptime without having to have multiple availability zones and boiler failover and all the things that, you know, they like to sell.

22:03 Yeah.

22:04 And yet getting to that point for people who are new, just the act of local versus production database stops people, like every single person, right?

22:11 They build the site, like it's a blog, and then they deploy it and they're like, "Where's my blog?" And it's like, "Oh, well that database "is different than this database." Like, you know, after a while I get used to that idea, but it's like, the code is there, why isn't the data there, right?

22:23 And then, so it's just this scale of up to how many nines do you need.

22:28 But most people are focused on just put something up online and add continuous integration.

22:32 I mean, really, what are the basics, but they're not basic when you're doing it the first couple of times.

22:36 No, they're not basic. They're not basic at all.

22:38 So having something that kind of automates that, I think another thing is, you know, you have different team members or if you're an individual developer, maybe getting something up on the web. I know people I've spoken to about how daunting it is. Going from got zero web apps published to one is a major challenge, right? Like, I don't know Linux, I don't know the terminal, I don't do SSH, I don't understand the security, I don't understand the best practices.

23:03 Like I just can't, you know.

23:05 Well, and that's something I emphasize in my books is getting something as fast as possible.

23:10 It was a little bit smoother with Heroku than Fly, but Fly is still pretty, like I take some shortcuts, but I say they're shortcuts, you know, this isn't the most secure thing ever, but just getting something up that first time because it doesn't have to be crazy complicated. I think the sooner you're dealing with a real live website, the better for many reasons. But yeah, that first one.

23:28 You know, you've spent all this time building your application, you're finally ready to you know, put it online and then it's like, oh, learn about servers and learn about firewalls and learn about rewrite rules and learn about permissions and groups and users and Caching, yeah.

23:44 Well, I just say Django has a deployment checklist to help with this, but I still think and others may agree with me in the community that the local to production gap is a big one that Django could do things to address.

23:55 For example, like everything defaults to local setup.

23:58 The deployment checklist, yes, a great resource.

24:00 I spend a lot of time in my books covering this, if you want, you know, hand-holding.

24:04 Oh, and it's not just a checklist on the web that you look at.

24:07 You can run manage.py, you know, space check --

24:10 Yeah, it's a management command and there's a whole, I guess it would be the, I think, how many, 12 or something now is sort of the, like, really don't launch it without this.

24:17 These aren't even optimizations.

24:18 This is like, just don't leak secrets everywhere.

24:21 But still, for Django, and I think for a lot of places, there's a tension, right, between how friendly you are to beginners versus advanced users.

24:27 And I think Django overall has done a very good job of still being friendly to beginners, but every most technologies over time, you know, move towards where the hardcore users are, because that's who's kind of doing this stuff. So that's a attention Django feels Python others, you know, how do you still keep it beginner friendly, but the people who are in charge want different things often, that's a real tension and programming and frameworks and all sorts of things. And I also think that that's why Python is so popular, honestly, right, you can do C++, you can do rust, like these are These are really great for advanced people.

24:58 You can do, you know, VB6 or super simple old school things that are great, easy for beginners.

25:04 But like Python is easy for beginners, but you can kind of bring in some more advanced stuff.

25:09 You can bring in async, you can bring in generators, you can bring in ORMs, but you don't have to.

25:14 Where a lot of languages are like, guess what, we're gonna start with a void voice, void star star, we're gonna go from there, you know?

25:21 - Well, the old saying was second best for everything.

25:23 And I think that's not, you know, I think it's first best in a number of places now too.

25:27 - I agree.

25:28 I think people say that, but I think honestly, it's really, if it's not the first best, it is on par with the other first best, right?

25:35 It is a front running contender for a thing where I would say it probably is, you know, the undisputed king is in data science and machine learning.

25:43 - Yeah, it's all the libraries.

25:44 - There's not a competitor out there that is near the level of depth in the ecosystem.

25:49 - Well, because there's R, and R doesn't have open source in the community that Python does.

25:54 - Yeah. - That seems to be, I mean, most, like here in Boston, a lot of friends are scientists and it's either R or Python, and they all kind of want to use Python, but sometimes they use R, but Python just can do more things.

26:05 So depending on what you need.

26:06 - The next episode I'm going to release, which I've already recorded, but I haven't released, so you all don't know about it necessarily, is "Shining for Python," which is pretty interesting.

26:15 Like that's the R web story coming to Python, which I think is just more cool stuff you can do in Python, honestly.

26:21 - Actually, I need to check the Python version of that, 'cause one of the, we just had DjangoCon Europe earlier this year, and one of the people who came up to me is someone who worked for the, what do you say, the UK government on their putting systems together, and he had bought my books to get his team to move--

26:36 - Maybe started with double O or something or other, I don't know.

26:39 (laughing)

26:39 - No, not that cool.

26:40 You just COVID information, health stuff, NHIS.

26:44 Is that, yeah, Nathan and Holt, NHS.

26:46 - NHS, I think.

26:47 - They were able, so he had said, though, that they were able to use R and use the, what is it called, the Webby to put things online, But for interactivity, that's where they hit problems.

26:56 So he and his team of 12 had moved a lot of stuff over to Django for the just more interactivity of it all.

27:03 But this is something the British government was doing.

27:06 So it's an area I wanna learn more about Shiny and how all that works because it's always been like, why can't you just take a Jupyter notebook and put it online?

27:14 I mean, right, like often put online.

27:17 So I'm trying to understand that too because the data science space is so big in the web space feels small in comparison, but yeah, I look forward to that episode.

27:25 - My quick takeaway, talking to Joe there, was they really thought about how to make it the Pythonic way, and it seems like they really embraced it, not just, "We'll get it to run on Python," but it seems like it's gonna be a good option for people out there, so that's really cool.

27:38 I wanna make sure that we talk about some of the history of Django and the future of Django, but I know something that all three of us are super excited about is HTMX.

27:47 So let's, and we were talking about it, front end stuff and the back end.

27:51 And so I don't typically share jokes on talk python that much.

27:54 It's more Python bytes the show at the end there, but there's this great meme and it has the back end dev and it has HTMX two people on the HTMX one.

28:03 Speaking to the back end dev says, look at me, look at me.

28:05 HTMX is talking to you.

28:07 This is full stack.

28:08 Now you're full stack.

28:09 Now, come on.

28:09 You're not just a back end developer.

28:11 You're full stack.

28:12 Cause you're doing HTMX.

28:13 And I think, you know, it's funny.

28:15 Also the thing called X that is kind of Twitter and half X and partially branded.

28:20 That is a whole different joke.

28:22 But I think just this joke up here, it really touches on something that I think makes Django, makes Flask, make all the Python web frameworks way more holistic and important coming back to build these apps.

28:36 It's not just like, well, we have to use React, so we're going to push you to just write JSON and points and so on.

28:42 Like, no, you could actually flip that and just embrace Python more with HTMX.

28:47 Who wants to start riffing on HTMX and Django?

28:49 Carlton, you go ahead. This is more of your...

28:51 No, it's exactly that. So, I mean, two years ago, three years ago, it was all like, "Oh, Python's existential threat because everything's going to be rewritten in JavaScript because, you know, everything on the front end is JavaScript. And so it doesn't make sense having these two languages. So it's all going to just swipe over and Python's going to disappear in in a puff of JavaScript. Well, now it's kind of like, well, really, is that is that what I see happening? Not No, what I see is the super established, mature web framework showing the real strength of the HTML tooling and the hypermedia tooling that they've, you know, it's just so fully developed. I mean, Django is 18 years old, summer, right? So there's a lot of history there. There's a lot of development time gone in, there's a lot of richness. And Once you start using HTMX, it really is, it's like, "Oh, do you know what? This just fits the patterns that Django wants you to use." It works with Django forms and just, "Oh look, it's just a form view. And all I do is add this little header in and, oh look, I changed the template maybe. And oh look, it's a fully interactive, rich client that the users can't tell the difference between that and a full SBA you built with Rack. Or perhaps they can because it loads quicker, because it's not, it's actually faster.

30:06 And one of the great reasons for switching to SBAs was they were meant to be quicker.

30:09 But the reality is, after all these years, they're loading so much JavaScript into the page and doing so much work in the browser in order to get the HTML to be interactive, that in fact, they feel slower to the user.

30:20 So for people who don't know, HTMX lets you put attributes on HTML, not complicated stuff like if you had an image, you could say hx-get and give it a URL.

30:30 You could say hx-target is some other thing.

30:33 So if you click on that image, it'll go get this context, talk to Django, pull back a fragment of HTML and pop it with possible animations and transitions and stuff into another section for like a master detail, like list details, view story.

30:48 It's just as nice as most single-page app, most front-end frameworks.

30:54 I suppose if the thing completely loaded all the different data and had zero server interaction, but then the startup time of that would be completely bad, like you said, Carlton.

31:04 So it's fantastic.

31:05 And let's go back to like the beginner and the people doing simple stuff.

31:09 HTML is not just for beginners, but it really works well for them because they no longer have to learn a different framework or never different language and a framework like JavaScript and Vue.

31:20 They don't have to write APIs.

31:21 They just do the thing they're doing.

31:22 And all of a sudden, all this cool interactivity comes in, right?

31:25 Yeah. And like for a decade, it hasn't felt to me, you know, I'm 20 years in the business.

31:30 I know how to do quite a lot, but for a decade or so, it hasn't felt to me feasible to be building web, good high quality, professional quality web applications single handed. But it feels like that again. It feels like, you know what, I don't need a whole team here.

31:45 And with interest rates going up and inflation going, you know, money being tight now, I honestly think there is a real big commercial competitive advantage coming back to sort of the backend. And that's not just Django, but Django, Flask, and Rails even, if you want a different language. But those kind of stacks where you can produce a really competent CRUD backend in very little time. And then you can produce the front end that's rich enough and feels good and feels developed for a fraction of the team size, one, two developers instead of five, 10 developers.

32:22 This portion of Talk Python to Me is brought to you by us over at Talk Python Training.

32:27 Let me tell you about one of our really popular courses.

32:30 HTMX plus Flask, modern Python web apps hold the JavaScript.

32:35 HTMX is one of the hottest properties in web development today, and for good reason.

32:40 You might even remember all the stuff we talked about with Carson Gross back on episode 321.

32:45 HTMX, along with the libraries and techniques we introduced in our new course, will have you writing the best Python web apps you've ever written. Clean, fast, and interactive, all without that front-end overhead. If you're a Python web developer that has wanted to build more dynamic, interactive apps but don't want to or can't write a significant portion of your app in rich front-end JavaScript frameworks, you'll absolutely love HTMX. Check it out over at talkpython.fm/htmx or just click the link in your podcast player show notes.

33:17 I think it also speaks to the wisdom, I would say, of, so Django has a templating language, but it's deliberately basic. You can use Jinja, and Django by design, because 18 years ago, the idea was, well, we're not a front-end framework, who knows what's going to happen?

33:31 And that provides the opportunity for, HTML comes along, just slide it right in. Like Django is not, doesn't have all this stuff built on top of it, trying to do that too.

33:41 So that can be a frustration for beginners, that why doesn't, why don't the templates do more. They actually do a lot, but it opens it up to HTMX. And then there's Django has third party package system. So there's one that Adam Johnson, who's a member of the community has Django HTMX that has extensions, like basically everything you want to do, you can kind of copy and paste it in. I mean, understand what you're doing. But so this, yeah, Django HTMX is a great resource.

34:05 But it's not, it's not rocket science. It's not, you know, you're not reinventing the wheel, right? You have a list view, detail view, you want to do auto scroll, you want to do some some validation on a form. It's the same solve problems out there. You just have to know where to look.

34:18 You go quite far with it. Yeah.

34:19 That would be an interesting question of where do you really need to not use it? I mean, certainly even in a team setting, like it's just such less complexity, and it's arguably faster and it gets you what you need.

34:31 Where do you not use it? So I'm building a quite rich drag and drop interface for a tool.

34:37 It's pretty complex. It's pretty interactive. And I'm using Alpine to do that on the page.

34:42 And then, but when it comes back to the server request, then dropping back to HTMX to send the things and get a chunk back. And I can quite often replace either a part or all of the Alpine component with the stuff from the HTMX. So it's still using rich JavaScript in the client where you need it. But you go an awful long way before you need that. And you're dropping in forms and you've got a nested list view and you're fetching that nested list view and dropping that in place. And that's in a modal, which is perhaps powered by Alpine. And it looks rich and smooth, and it's, it's everything you want. But the amount of code is very minimal.

35:18 It's progressive too, right? I mean, Vue.js, when it first came on the scene, I forget if it's still doing this, but like its whole thing was the progressive, you know, you don't, you don't need the full React bundle, you can kind of ramp your way in. And so I think there's just more ways to get from here to there. And you don't have to just go to APIs and the full blown thing.

35:35 I have to admit, last week, I was, or perhaps the week before I was sitting there, I was doing everything with HTMX. And I was like, I need a full page load here. I need it to refresh the whole page. How do I do that? How do I do that? And I had to step away, go and get coffee. And as I was boiling the kettle, I was like, oh, I could just submit the form normally. I'll fall back to just doing what the browser does by default. Oh, yeah. Okay.

35:57 You just always have to think if it's getting clever, like you're missing something.

36:00 Yeah, yeah. No, it's exactly that. It's like, I was so in the zone, I'd forgotten the base technology I was using.

36:06 I did a talk at Py Bay food cart edition a couple years ago, and I was talking about it on X, whatever that thing, and we're going to have to figure this out.

36:14 That thing might be gone pretty soon, but we'll see.

36:17 Anyway, I was talking about it, and I said, "Look, you can write these awesome web apps with Python, you don't have to use JavaScript." And somebody's like, "Michael, that's really insensitive.

36:25 People, you shouldn't be degrading the JavaScript developers." And I'm like, "That's not the message.

36:32 It's the message that the language you choose, whatever it is, you can just embrace that and do a lot more.

36:37 And like the biggest example of that is that this is a popular framework in the Node community, which is JavaScript.

36:45 And the big value here is that you don't have to also have APIs, you don't have to also have a frontend and a backend framework in the context.

36:52 Like, you guys probably know, teaching how people deploy stuff is like, well, there's what your frontend can do, and then there's the security of the browser, and there's all the constraints of that.

37:03 and then your backend server, oh, it can talk to the database directly, and it could do these other things.

37:07 But with HTMX, like, your front-end code executes in the same context as your backend code.

37:12 So you don't have to have, like, two security models, two runtime models, two all these, two conceptual ways of like, well, what's, okay, it's happening here, so that means this.

37:20 Like, no, it like all happens in one place.

37:22 And that's even valuable if you were doing Node and JavaScript.

37:25 - Yeah, no, absolutely.

37:26 I think there's a, on the HTMX website, there's an awesome essay, it could be the intercooler, but it talks about this impedance between the two sides.

37:34 And the example it gives is GraphQL, I think.

37:37 And the GraphQL gives amazing power onto the front end and you construct all these queries, but are they safe and who knows?

37:43 And what companies end up, often end up doing is whitelisting the query.

37:47 So it's in fact, you can't leverage the full expressive GraphQL in the client because it's only a certain number of queries which are allowed in order to get over this security problem.

37:56 Those essays there are just phenomenal.

37:58 - We should mention, so Carlton's given two talks this year, one of them at DjangoCon Europe, he touches upon the locality of behavior.

38:06 I just put in the show notes for you, Michael.

38:08 It's one of the essays, but some of his projects, I saw everyone around me was writing down, perhaps you want to expound on that idea, Carlton, because it's not necessarily a new idea, but it really seemed to resonate at DjangoCon with people.

38:19 - The talk was called Yak Shaving, to where the puck's gonna be, and it was about, it's just been about what I've been doing since I stepped down as a fellow in end of March.

38:26 So April, I sat down to start writing software with Django again, rather than on Django, as I said at the beginning.

38:31 And the sort of the hook that I built the whole talk around was HTMX and this idea of locality behavior.

38:37 And so the example that I gave in the talk, and which is from the essay there is, HTMX has got just the one HTML file open versus a jQuery example, which is very similar, but it's over two files.

38:49 And, you know, if you just, it's not the only consideration, but in that one case, you've got one file open versus two files open, well, there's better locality of behavior where you've got one file open.

38:58 And that really, when I read that essay, really like struck a bell with me for years, I've been talking to clients about this. And you've got a form a Django form, and it's perhaps only got four lines or three lines, it's virtually nothing. And it'll be off on its own in a separate form stop pi file, rather than next to the view you're working on. And so you have to go and open that second form stop five pi file to see the form. And it's always just declares the fields. And that's all it does. And then you go back to the view.

39:23 And you have to kind of remember it was if you just move that form kind of next to the view, all of a sudden, it's all within one screen on your, on your editor and you've, it's much easier to understand.

39:33 And then you're kind of, your, your speed of development increases.

39:36 And the more I've been playing with this, the more I've used this, it's just like, yeah, actually I'm able to, I'm able to work much faster by focus, particularly of a new code, like when your code starts to get bigger and more gnarly and more curly, and there's more bits to it, then, okay, you want to break it out so that it maintains, it remains maintainable.

39:54 But when you're first working on it and there isn't much of it and it's constantly in flux, keeping it all together. It just helps you go faster. It's this idea of locality of behavior. It's, it's, it's phenomenal. I'm just a massive fan of it.

40:06 Yeah, it's really a brilliant framework. And so for Django people, Django dash HTMX, that's where the magic is to get it easily integrated.

40:15 Yeah. So that's a, the basics of that is a middleware, which will add a few, an HTMX attribute to the request object, which lets you query it. So is this an HTMX request?

40:23 Has it got this header? Is it wanting to redirect? Is it wanting to do a full page refresh? Is It got, you know, the various headers that HTMX sends, it'll add those and a few other niceties as well.

40:33 But yeah, you may as well use that.

40:34 That's a good package from Adam.

40:36 It's one of the cool--

40:37 - Adam knows what he's talking about.

40:38 - Nice, all right.

40:39 Django, 18, 18 years old.

40:41 - Yes, amazingly, amazingly.

40:44 It's old enough to vote.

40:45 - Yeah, old enough to vote, yeah.

40:47 - It is old enough to vote, not to drink yet, so it's not gonna get into trouble on the server for a few more years.

40:52 - It is on its holiday.

40:53 - Okay, well, that's true, yes, okay.

40:54 In Europe, it actually, it totally is.

40:57 I remember when we lived there, my daughters were 16 and we took them out for their 16th birthday.

41:01 So yeah, but in the US we have these rules, you know.

41:04 - Two things, so Django has major releases update every eight months.

41:08 So 4.2 came out in April, 5.0 come out in December.

41:12 In between there's 4.2.1, 4.2.2.

41:15 This is all the work the fellows, Carlton, would do.

41:18 But there's also, so in the Django News newsletter, there is almost every day there is a new PR accepted and merged into Django.

41:26 So on the Django news newsletter, one of the things we have now is a section highlighting like the changes this week.

41:32 And I think last week there were 18 new PRs and that's not just someone opening it up.

41:37 That's like open, discussed, accepted, reviewed.

41:40 Like there's so much activity going on.

41:43 So even as it's 18 years old and it is mature, there is still just so much happening.

41:48 And I think that's one of the messages Carlton and I try to get to people is like, it's not just this static thing at all.

41:54 There's so much that's happening and yet it won't break on you, unlike some other newer technologies.

41:58 I mean, talk about the influx of tickets just while, why does Django need fellows?

42:05 The reason these fellows is because there's basically five new tickets every single day.

42:09 It's over a thousand new tickets a year, you know, 1200 new tickets a year, every year.

42:13 And they keep getting handled.

42:15 They keep getting dealt with.

42:16 The PRs keep getting merged.

42:18 The security releases keep coming.

42:20 And without the fellows, it just wouldn't have happened.

42:21 Django would have sort of just ground into an ever bigger ball of unanswered tickets, unresponded, you know, things.

42:28 And so without it's a project of such a size that without the paid role, it just wouldn't be maintainable.

42:34 Some of these do get resolved. I mean, how long was Lily's one on database constraints?

42:38 That was like 13 years, 12, 13 years.

42:41 Yeah, tell that story.

42:42 This is one of my favorite features of Django 5.0.

42:44 It's come out. So we haven't even talked about Django 4.2, but Django 5.0 is coming out soon.

42:48 And in there, so there's some really big ones, there's database defaults.

42:52 So you've always, on a model field, you've always been able to declare a default value.

42:56 So, you know, if there isn't one, give it a date time field, give it now, if it is a classic default.

43:01 But those are from 5.0, you'll be able to declare those as database defaults, which may not sound like much, but A, it's quicker, it's moving work into the database.

43:09 But B, not every connection to your database goes by your Django application.

43:13 So you're able to have database level default.

43:15 And so if there is a script, isn't using the Django ORM, then you still get the value of that. And that ties in with work that's been done on constraints with database constraints have been massively powered up. And they'll even now, you know, your form generation will generate validators that are based on the database constraints. And it's just so much richness coming out. I think I really think we're also going to get database cascades in Django 5.0. It's so it's nearly ready. There's a month or so before the feature freeze, I think it's going to go in, in which case, we're going to have DB defaults and DB level cascades, both, you know, added to Django both of those, it's a decade or more in the resolving in a new release. And that's it's just, oh, wow, that's really exciting.

43:57 Yeah, for a lot of people, a lot of companies, the database is the source of truth for the apps, right? And like, sure, your code may talk to it, but what is in the database, like there are people whose job it is to defend the schema, they call them DBAs, right?

44:13 - So Django 4.2 added DB comments, so you could add schema level comments to your model fields to explain the use of the model field.

44:20 Again, it's for--

44:21 - Those scenarios, yeah.

44:22 - For people who are serious about their databases, that these features are just massively important.

44:26 - Yeah, I think it's certainly worth considering that there will be other apps, there will be other tools, and maybe even data science, right?

44:33 The data science angle is huge, often wants to now talk to the database.

44:37 And even if it's in Python, it's unlikely that in Jupyter you're gonna pull in your ORM, you're probably using some other data science oriented library to talk to that.

44:47 And so pushing those defaults down is viable.

44:49 - Well, so Michael, you're as situated as anyone to answer this.

44:52 Carlton and I are in the Django world, but how do we bridge the data science to web?

44:56 Doesn't need to be Django world.

44:57 Like what, do they need to be on the web?

44:59 And if so, what's holding them back?

45:01 'Cause it just feels like this megaton star of data science in this tiny little web thing.

45:06 But how do they share stuff?

45:07 How do they interact with it?

45:09 - Yeah, you've got your notebook and then you wanna publish it somewhere, right?

45:12 - Yeah, or just share your information or you have a database of COVID things.

45:17 For example, in the UK, you wanna put online but let people make change in some way or make requests.

45:22 I mean, the data isn't generally static.

45:24 - So I think there's two answers from my perspective.

45:26 I think there are the frameworks that are doing that and that would be things like Streamlit Dash, not Dashly, but the other dashboarding one.

45:35 There's Panel, I say Streamlit, probably started with that one, right?

45:39 So those kinds of things where you can get like kind of a simplified view that's kind of an interactive thing.

45:45 You wouldn't look at it like we're looking at this Django site and go, yeah, it looks like, it feels like this, right?

45:49 It doesn't feel like that.

45:50 It feels like you pushed a kind of an interactive generic UI up.

45:54 But I think that's a pretty good answer for a lot of people.

45:56 I think another is honestly, the stuff with HTMX, right?

46:01 You need a lot of interactivity in many of these things, these data screens and to get that interactivity often.

46:08 But you also need it to remember, Yeah, yeah, you need it to remember, we computed this stuff and I want it to like, get me the other info and you kind of need a, just because how long it takes to do a lot of the computation, you want a somewhat stateful type of behavior.

46:23 And I think HTMX with Plotly or something like that, even Matplotlib, I've done some Matplotlib stuff and just like returned it as an image in different areas and yeah.

46:33 Carlton, what do you think?

46:34 Yeah, no, I'm nodding, that's a good approach because you know, you can quite easily put in a little loading indicator there and it will when the HTML is ready and just even if it took the same amount of time by just putting in that little animation while it loads, it feels as if it's responsive and doing something and it's not rocket science, but Hx dash indicator. Yeah, yeah, I was nodding, particularly when you said just use matplotlib and pull it in as an image.

46:57 It's like, yeah, that work that goes an awful long way doing that kind of thing.

47:00 I wasn't familiar with Streamlit. That's really cool. I mean, it makes sense. I'm like, there's got to be someone, some people doing this solving this problem. But Yeah, Streamlet is really, really interesting.

47:10 Basically, you put dec-- you have like a regular script that's not even a web thing, and you put decorators onto the functions, and it says, "Oh, this parameter here is going to be a combo box or something," and it knows how to like wire the-- it's some voodoo, but it's cool.

47:25 But it does look like a Streamlit app, right? It doesn't look like, "Well, here's my own custom website." It's like, "Well, here's my Streamlit app that I built for you," right?

47:32 - Right, but I mean, and yet, you know, many people are using Tailwind now, and so every site looks like a Tailwind site, and before it was Bootstrap, and before, you know, so it's like, we can't get too high on our horse about it, you know, 'cause at the end of the day, it's like, it just needs to look modern-ish, and like, move on.

47:47 - Yeah, absolutely, absolutely.

47:49 And getting something out is super important.

47:51 Okay, so Django is, I would say it is the oldest, popular Python web framework period, right?

47:58 There may have been ones before, but it certainly seems to be of the few that are like really, really popular.

48:04 The one that's been around the longest.

48:06 What's amazing for me about it is the way the community kind of keeps refreshing itself.

48:11 Like it's not like the founders of Django are still merging every commit and every PR.

48:17 Far from it.

48:17 But you know, I think Simon Willis made a commit in either 4.1 or 4.2, I can't remember.

48:22 It was his first one for six years kind of thing.

48:24 He doesn't even live in Lawrence anymore.

48:26 I mean, none of them.

48:27 Yeah, exactly.

48:28 What right has he got?

48:29 But the point being is that it was set up to liberally to like, hand it on, let it go.

48:34 And it's, I think Django is probably on its fourth or even fifth cohort of generation of kind of maintainers now.

48:40 And yeah, that's a whole fresh batch of faces in the community who are doing new and exciting things.

48:46 And it's just so wonderful to see because you get old and long in the tooth and think, oh, I'm worried about the future of Django.

48:53 No, Django is doing great, actually.

48:55 At DjangoCon, we talk about Django things, and one of the things we don't necessarily describe to others is what makes Django different than other frameworks out there.

49:03 And it is the community.

49:05 I mean, Flask is an amazing resource, and David Lord and people do great work, but there's no Flask cons.

49:12 There's no, it's its own thing, but Django is relatively unique in that it has, it's a non-profit, it has fellows, it has conferences, it has this whole ecosystem of third-party packages.

49:23 So there's the saying, come for the frameworks, for the community. It really is true, but you can't get that across to someone who just looks at the Django website, which looks like what it is, which it hasn't been re-done in a number of years, right? You think, oh, maybe it's a little bit of a stale, crusty Python thing. It's like, no, it's alive. There's changes every day. You're just not seeing it. And it's hard to, you're HTMX, right? Like Carson does amazing work, but I think it's pretty much just him, right? It's not this community of dozens and dozens of people. And so one of the exciting things for Carlton and me is we're both transitioning away a little bit, but still helping bring in new people. And that's healthy, right? Like we know a bit, but sometimes I get, you know, I know the things that kind of I would like to change that may not change as quickly. And then new people have great ideas and enthusiasm. And it's like, yes, let me support you because I don't want to get stale with this.

50:09 >> Prajnapan asks a pretty good question, which I think is a good question for any really large project that's been around a long time. It's like, how do you get more involved with Django?

50:18 For someone who's not proficient in Django, like super, super proficient, given that it's a mature project, it's really hard to get that first PR written.

50:27 One thing that often comes up, "Oh, there's no low-hanging fruit. It's a mature framework.

50:32 There's nothing easy to do." It's like, well, yes and no. Yes and no. There are very few nothing fixes that an absolute beginner can just come in and get because they get snapped up really quickly and they just don't hang around for very long. But we've got something like 800 open accepted tickets on Django. Now of those 800 tickets, some of them are truly hard, like adding database defaults, which took a dozen years and five Django con sprints and you know, who knows what to actually get over the line. That's truly hard. But most of the tickets aren't like that. Most of the tickets are no harder than a problem that you're solving in your everyday Django or Python programming work. And what they need is time and love. And so Django cons I've run Django sprints, I've run a kind of getting contributed workshop. And the goal of it, you've only got a couple of hours, it's only like half a morning. And the goal is not to necessarily get your PR in, but it's just to get you to look at a ticket in a bit of depth, git set up with a test suite, you know, install it, git set up, but git involved in a ticket and come to understand that ticket. And realize that actually, after that a couple of hours of thinking about that ticket, you are literally the world expert on that ticket. And even though you're not like, "Oh, it's established. I'm not a Django fellow. I'm not an established contributor." You, as the world expert on that ticket, you have a valid opinion and your insight will be valuable.

51:50 And yes, you have to dig around and you have to learn some source code, but you'll have an idea and it's going to be on the right track. And if you put the time and work and love in, you'll be able to resolve that ticket. And once people have had that experience, then it's like, "Oh, I can can do another one and I can do another one and I can, it can become the little side hobby.

52:08 And actually then I'm a Django contributor. So it's take your time, pick a ticket, really focus on it, become the world expert. And in so doing, even if you don't resolve the ticket, you will learn an awful lot about Django. You think you know Django by developing Django apps all day. Well, you start digging around in the code, I'll guarantee you'll know it a lot better afterwards. So that was be what I say is find a ticket that grabs you and just take that little bit of time to really understand it.

52:35 Yeah, that's great advice. I guess there's probably sprints you could drop into at some conferences.

52:39 Yeah, so after the Django concerts, there's two days of sprints. Stay around. There's a really great opportunity to meet people who are contributing and to get into contributing and be able to sit in the same room as somebody and say, well, you know, how do I get started?

52:52 How, you know, that is a good, a good play.

52:54 Can I just sit there and look over your shoulder as you two work on this? And yes, let me be clear.

53:00 DjangoCon. So there's DjangoCon US, DjangoCon Europe, there's going to be a DjangoCon Africa this year for the first time. But the most recent DjangoCon US, I was at a sprint talking with David Lord, who's the lead maintainer on Flask. And he had a question about something or other.

53:12 And someone was like, oh, like Simon Wilson knows about that. So I was like, oh, grab Simon over.

53:17 And they'd never met. And now it's like, oh, like, so if you can stay for the sprints, it seems like the nothing part, it's actually, I'd almost take the sprints over the conference, if you could, because it's literally just like anyone you want to talk to. And you don't have to, you know, like, what are you working on? Or, yeah, they're like the best part. But maybe it seems intimidating, but it's really not. And to Carlton's point, the community really is welcoming.

53:38 So even if, especially if you're inexperienced, if you're making an effort, and people can see that, they will be encouraging and want to loop you in. There's also I should mention, there's a new Put A Link program called Django-Naut that's trying to pilot having some mentors to give this this kind of hands-on help a little bit.

53:55 That's a new program.

53:56 It's only, I think, six people right now, but they're trying to foster more mentoring of this type.

54:02 But it is a challenge for a mature framework, right?

54:04 You probably can't just go fix HTML.

54:06 It's probably a little more meaty.

54:07 But it's not all hard just because it's there.

54:10 It's just that it got stuck for whatever reason.

54:11 It needs, as Carlton said, that oomph of someone to come in and put a couple hours and then be the world expert.

54:17 - Absolutely.

54:18 So what's the async story, Django, these days?

54:21 How's it looking?

54:22 - It's looking really good.

54:23 So in my, so do we get to talk about 4.2?

54:25 Yes, Django 4.2 brought in async support for streaming responses.

54:31 So within the core framework itself, you can do service and events, or you can have a request come in, you can keep it open without blocking the worker, and you can periodically send messages down.

54:41 That's really quite exciting in 4.2.

54:43 And with the other thing that came in 4.2 was PsychoPG3, which is our async database connections.

54:51 And so there's a link in the show notes there of somebody put together exactly what I was hoping for, which was the chat example, but done 100% async.

55:01 So without blocking ORM call with the server-sent events, so instead of long polling, or without having to use an add-on like channels, which add-on channels is great if you need it, but isn't it cool that you can do server-sent events just in Django?

55:15 And then in 5.0, which is coming, we're gonna have HTTP disconnect handling in so there's long lived requests.

55:21 If the client disconnects, you'll get an async IO cancel there in your view, and you'll be able to respond to it and do any cleanup.

55:27 We've also in 5.0, we're going to have async signals, which gives you an 100% async request response pathway if you want it, because before the only blocking bit there was the signals, which was synced, so you still had to do this sync to async, oh, sorry, sync to async, jump into a thread pool to dispatch the signals.

55:45 But that, if you've got async signal handles, will all be async as well.

55:49 So the entire request response flow can be async.

55:51 And then sessions is going to be async in 5.0 as well.

55:56 Auth is going to be async as well in 5.0.

55:59 So those kind of core flows are, this is on top of the async interface to the ORM, which was added.

56:06 You know, it's all fleshing out.

56:07 And there's a few decorators, which, you know, aren't yet done, but they'll be done over the next few releases.

56:12 It's really enriched.

56:14 And it's like, yes, yes.

56:16 five, six years, seven years of work has gone into this, and it's really maturing nicely.

56:21 So I think asyncing Django is a very, very exciting time.

56:24 So when people say I want a fast, yeah, FastAPI, right? That's always the thing. Well, why not just use FastAPI?

56:29 Well, no, if you want to use FastAPI, go use FastAPI. But if you're using Django, but you need a couple of these endpoints, which you need higher throughput, or, you know, what it or an, you know, a real time or two or two directional traffic or whatever, you shouldn't have to switch red framework just to have a couple of these, these, these endpoints, right? It's like Python needs to be in every area because you shouldn't have to switch language just because you need, I don't know what, to be a bit more serious about things. So Python needs to be able to account for those more serious use cases. Well, same with Django. It needs an async story because you shouldn't have to change your web framework just for, you know, service and events or I don't know what other async, you know, a bit of real time. Almost nothing waits on other things like web frameworks do. They wait on database calls, they wait on the network, they they wait on caches, you know, like Redis, they wait on maybe calling other APIs, like almost everything they do is coordinating other systems and waiting and then turning that to HTML or JSON.

57:24 And so having rich async support is fantastic.

57:27 Yeah, no, I mean, it's really coming on.

57:29 And there are still, you know, there are bits inside, you know, I don't know if you need the user passage test, decorate, permissions, decorate.

57:36 Is that yet async defined? I'm not sure if it is.

57:39 Okay, that's not, we haven't got to, maybe we have, I need to check, but we haven't got to that bit yet.

57:43 But okay, those kind of bits, we'll get there with those.

57:46 But that kind of core, I'm building something on the request response cycle with auth, with sessions.

57:52 Yeah, that's all now done.

57:53 And so it's really maturing.

57:55 - Getting short on time here, guys.

57:56 - It's so nice to have you being in charge of this, I should say, right?

57:59 'Cause whenever there's those pauses, like my instinct is to jump in and like, look at our notes, but like, just like, nope, you're captain of the ship, it's so nice.

58:06 - Yeah, we're just out for a sunset cruise in the old boat, we're coming back to the harbor.

58:13 So what else about the future?

58:15 We talked about Django being 18, a lot of the cool ideas and projects and resources, but what about the future?

58:22 Some of which we just covered is really exciting, maybe we haven't given time to yet.

58:27 - I'm personally excited about the new people getting involved.

58:30 I know that's not as tangible for folks, but coming from DjangoCon, coming, like I just stepped off the board, I was treasurer for three years. I know who the new treasurer is, the current president.

58:41 I'm really excited about the new people. And so I don't... For a while during COVID, I think some of us had concerns about how do we keep this afloat and not have everything crash and burn. But I don't have those concerns anymore. And so just the fact that if you want something in Python that solves almost every web problem you have and has a really supportive community, Django is still there for you. And so I guess that's the big one. It's just, and I think from a marketing side, it's just how do we express that it's still cool and interesting and powerful, and yet won't break on you. It doesn't seem as shiny and new as the next whatever, but it's, you know, it's like, if you look on Hacker News every like six months, someone's like, wow, Django is like still around.

59:22 Oh, it's like, kind of solves all these problems we have with this new JavaScript, this or that.

59:26 It's like, yeah, it's still just doing its thing. So I would say the community side, I mean, also So like I've got projects, if you want to learn Django, I mean like, there's a lot of resources to learn it.

59:37 There's videos, you have videos, books, tutorials, like some of these newer technologies, it's harder, there's not a community, and it's harder to find the resources.

59:47 There's a lot of strength in being around for a while and yet not being totally stale.

59:51 So that would be my tagline for Django, how's that?

59:53 - I kind of go off that, I think actually it is cool, and it's about as cool as it's been for a while.

59:58 I said in my DjangoCon Europe talk I'm as excited about the framework and where it's going now as I have been for many years since I said since the DRF kickstart, if you remember that back in the day. There are over the last few releases, and I don't just mean 4.2 and 5.0 coming up, I mean like the last 3.2, 4.0, 4.1, like last few years, there've been a number of threads, not just the async stuff. There's been massive changes to the forms, templating. There's been all these changes to the ORM that are powering it up every single release. And they've all come together and there are patterns now to be discovered. And it's like I said, I'm stepping down in part because of life, but in part to get back to working with Django rather than just on Django. I want to play with all of these new toys that we've built over the last few releases. And I want to discover those patterns and see them codified and see them come out in the community. And it's just a massively fertile time. And so that's what I'm excited about. That's where we're going. And I can't say every release Django literally gobsmacked by how many new features you think, oh, there won't be any in the new one.

01:01:01 But it got to be done again. Yeah, but 5.0 is coming out and it's just hitting out of the park again. And it's like, wow, we've only just had 4.2. 4.2 is not even old yet. 5.0 is not even in alpha. And we're already thinking, oh, can we run it off main because it's so exciting.

01:01:16 The future is so many things have come together. The future is just really exciting. So that.

01:01:20 Yeah. And I'd say I feel like I would be bored by now with Django. Like I've only been doing it for over a decade. But like I'm, if anything more interesting, there's just so many new features, but also I'm understanding built in functionality even better to solve problems that I just had didn't have before. So at some point, maybe I'll be like, I know it all. But I feel the opposite.

01:01:38 I feel like, whoa, like I had no idea. Just one concrete example, doing all the work with templates and HTMX and like coming to see the patterns about create, you know, again, fresh for the first time in use really using templates for the first time in half a decade.

01:01:52 it's like, okay, ah, yes, I create a template tag here. And I do it this way. And I use I put a mapper in here to create a kind of view model type thing. So I pass in an ORM model object into the template tag. And then in the template tag, I map it to what I need in the actual template itself, then the template comes in. It's like, oh, that's a really good and powerful pattern. And it's really encapsulated and neat. And it makes my template expressive and rediscovering these things. And then being able to say, right, okay, well, what changes does the Django template language needs that it hasn't had in quite a few years because no one was using it.

01:02:24 And yeah, it's just a massively fertile.

01:02:27 It is. And it's no coincidence that we've been hitting on HTMX so much because it really puts the power of frameworks like Django back front and center and how you think about building and structuring your web apps.

01:02:40 Right? It's not like, well, there's this thing in the back end, and then we're going to go do these other languages.

01:02:44 It's like, no, actually, it could be all.

01:02:46 And there's a bunch of cool features and capabilities that we've been talking about.

01:02:49 And you can use them throughout your app if you leverage something like not necessarily but something like htmx, which is really cool I think for me it works just with the grain of the framework It's like this is the way I would do it if I was writing in 2005 and I do exactly the same in 2023 and It just works and it's you know responsive and dynamic and all these nice things that you know clients want. Absolutely All right, let's leave it there, guys.

01:03:17 Thank you so much for covering all this and celebrating Django's 18th birthday.

01:03:23 18th birthday, yeah.

01:03:24 Yeah, it's awesome.

01:03:25 It is an adult and it's a cool framework for sure.

01:03:29 With really, I think it's the community behind it, especially the fellows and all the board and stuff.

01:03:36 It makes it really unique and it's certainly worth considering as part of the framework, right?

01:03:40 As you said.

01:03:41 Okay, with that, let's round this out with just a final shout out to what you guys have around Django.

01:03:48 For example, the Django Chat podcast, which is excellent.

01:03:52 Give us a shout about that.

01:03:54 Will, tell us about LearnDjango and maybe button.dev or whatever else you want to throw in.

01:03:58 - I should say, djangochat.com, you're sort of the godfather of it 'cause you gave me a lot of good advice when we were starting out in the early days around things and that there might be a market for it.

01:04:07 So thank you for that.

01:04:09 - You're welcome.

01:04:10 It's going strong.

01:04:11 It's a great show.

01:04:12 I enjoy listening to the episodes.

01:04:13 - We're gonna be back in the fall with new episodes.

01:04:14 And then learndjango.com, that's my main website. If you want to learn Django, access books, lots of free tutorials, premium ones coming. That's sort of an all-in-one resource. And I think there's also a link to Django-news, which is a weekly Django newsletter with new news that's happening, new projects, new tutorials, not just mine. So that's something I've been doing with Jeff Triplett for a number of years now. And that's a good way to stay in tune with what's happening.

01:04:38 Yeah, that's kind of an essential resource, I'd say.

01:04:40 And then Button, Carlton.

01:04:41 Yeah, so okay, so I'm, I'm, well, I've got a website and I've got a blog somewhere.

01:04:46 That's a button btn.dev that will be live in the autumn now.

01:04:50 And then but you can follow me on foster Don or the 30 verse and my website, there's an RSS feed, which you could subscribe to if you you fancy that.

01:04:58 My other big projects in the moment is working on a set of opinionated crud views for Django called Neapolitan, which is a bit of fun.

01:05:06 I'm having a lot of fun of that.

01:05:08 So watch my DjangoCon Europe talk for an introduction of that.

01:05:10 And then I'm working on a package called Django template partials as well, which is about getting template fragments into the Django template language, which again, - I was going to ask you about that. - I'm talking about Django on your talk.

01:05:20 I know, now that he's not a fellow, he can do all the things he always wanted to.

01:05:23 Yeah, when I started using this with Tristan, and I'm like, man, you have got to come up with a way to reuse HTML almost like functions.

01:05:34 So I came up with Jinja partials. So what is yours called?

01:05:37 Django template partials.

01:05:38 - Template partial. - Django template.

01:05:39 Oh, you need a spacer.

01:05:41 A little, I think.

01:05:42 I think I put a link in the notes.

01:05:44 But yeah.

01:05:44 Yeah, there you are.

01:05:45 So that's my take.

01:05:47 And it just enables you to define reusable components.

01:05:50 There's a couple of pull requests open, which will just change the API there slightly.

01:05:54 And then we'll start to think about rolling into Django.

01:05:57 Hopefully for now, it's going to be Django 5.1.

01:06:00 There's no chance of me getting in for 5.0 this summer.

01:06:03 But it's the same idea.

01:06:05 And the point with it is it's integrated with the Django template loader.

01:06:08 So all you do in your view is change your template name variable, and you still return your template response, the same as you always had with the context.

01:06:16 There's no adjusting your view logic.

01:06:18 It's almost transparent to the view layer.

01:06:20 And there are, you know, I've seen people writing logic where they pass the HX vows, which is where you pass extra parameters in your request from the client, which you could then specify the partial with, and then your view logic wouldn't change at all.

01:06:33 That's out of scope for Django template partials.

01:06:35 But it's a possibility.

01:06:37 But the point being that you just it's this for me or something like it is how Django wants you to do pass partials with the Django template language. Obviously, with Ginger, there's an option as well with Django.

01:06:49 Useful outside of HTMX required for HTMX, basically, right?

01:06:52 Yeah, I mean, you because what's the other way? The problem with it is you are you then have if you don't have inline partials, you have to move it to a separate template.

01:07:00 And then you have to include that template in the other template. And that's great, a certain level of complexity. But again, it's this locality of behavior thing. When you're first starting, you don't want that heavyweight kind of you're in your creative flow, you're making progress. And all of a sudden, you have to put the brakes on to create a new file move open.

01:07:17 What's the what's the file name again? Oh, I've spelled it wrong. Oh, it didn't load. Oh, because it was in the wrong file. You don't want all of that. You just want inline that bit be reusable, please.

01:07:27 Yeah, very cool. Yeah, this is very, this is different. Mine doesn't embrace the locality behavior as much as yours does. So people should check this out. This is interesting.

01:07:34 Obviously, mine doesn't work with Django either. So that doesn't really matter.

01:07:37 Well, it works with Jinja though, right?

01:07:38 So it works with Jinja, right? Yeah, yeah, yeah.

01:07:40 And so the Django template, Django templates have swappable backends. So you can use the Jinja backend to use Jinja templates with Django if that's your cup of tea.

01:07:49 We got to end this podcast. But if you're looking at like moving a Flask project over to Django, that would be a way to not touch the HTML very much, right?

01:07:58 Yes, exactly. Because you could carry on using the same templates more. You might need one or two edits to the, what's it called, the Django environment, the Ginger environment or something.

01:08:07 Thank you guys for being on the show. It's always a great time to catch up with you.

01:08:12 Thank you for having us.

01:08:12 - This has been another episode of Talk Python to Me.

01:08:17 Thank you to our sponsors.

01:08:19 Be sure to check out what they're offering.

01:08:20 It really helps support the show.

01:08:22 Take some stress out of your life.

01:08:24 Get notified immediately about errors and performance issues in your web or mobile applications with Sentry.

01:08:30 Just visit talkpython.fm/sentry and get started for free.

01:08:35 And be sure to use the promo code talkpython, all one word.

01:08:39 Want to level up your Python?

01:08:40 we have one of the largest catalogs of Python video courses over at Talk Python.

01:08:44 Our content ranges from true beginners to deeply advanced topics like memory and async.

01:08:49 And best of all, there's not a subscription in sight.

01:08:52 Check it out for yourself at training.talkpython.fm.

01:08:55 Be sure to subscribe to the show, open your favorite podcast app, and search for Python. We should be right at the top.

01:09:01 You can also find the iTunes feed at /iTunes, the Google Play feed at /play, and the direct RSS feed at /rss on talkpython.fm.

01:09:10 We're live streaming most of our recordings these days.

01:09:14 If you want to be part of the show and have your comments featured on the air, be sure to subscribe to our YouTube channel at talkpython.fm/youtube.

01:09:22 This is your host, Michael Kennedy.

01:09:23 Thanks so much for listening.

01:09:24 I really appreciate it.

01:09:26 Now get out there and write some Python code.

01:09:28 [MUSIC]

Back to show page
Talk Python's Mastodon Michael Kennedy's Mastodon