← Back to Show Notes

Transcript: Django 3.0 Preview

Will Vincent

Hello and welcome to Django Chat, a weekly podcast on the Django web framework.

I'm William Vincent, joined as always by Carlton Gibson.

Hi, Carlton.

Carlton Gibson

Hello, Will.

Will Vincent

How are you?

I'm great.

And today we have exciting news.

We're going to talk about Django 3.0, which is coming out this December, but I believe the feature freeze has just gone into place.

So we're going to talk all about what to expect and a little bit about the process that the Django fellows such as yourself go through to make it happen.

Carlton Gibson

Yeah, so the feature freeze was the 9th of September.

And then we put the um alpha out on I think the 10th or the 11th, maybe the 10th.

And so that's available now.

So you can go to the website, you can um you can download that, you can pip install it, and then you can um you can test whether your app is compatible with Django 3.0.

And if you can do that, that's super.

So the the take-home message from this podcast is go get the alpha, run it against your test suite, and then please report if they've broken anything.

Because it's this time.

What we'd rather have is reports that we broke something now rather than the day after we released the final in December.

Will Vincent

Right.

So let's maybe talk about so what's going to be included, and then we can talk about what you know missed the cut and we can have looking forward to in 3.1, 3.2.

Carlton Gibson

Okay, super.

So the big headline feature is the ASGI support, the HGI um support, which is the async support.

So um this is the first step in the road to making Django async.

Um and Django from 3.0 will speak ASGI, which is the equivalent of Whiskey.

So WISGI, what's that?

It's the Web Services Gateway Interface.

It's the um the standard for Python web servers to communicate with um web application frameworks at the back end.

Um and so Djange is a whiskey, Django is a whiskey framework, Flask is a Whiskey framework, they're all Whiskey frameworks.

Um and up until now, Django has supported WISGI.

From the the the the step away, the the the evolution of that is towards the asynchronous gateway interface, which is ASGI.

And um uh channels speaks ASGI already, and Starlet speaks ASGI, and there's a few other frameworks out there that speak that.

Uh but that was now coming into Django Core.

And so from 3.0, you will be able to run Django, your old synchronous, your exactly existing Django with an with an ASGI web um front end, so Daphne or UVCorn or one of these ASGI front ends.

But what's kind of in what's interesting at that stage is then you can embed that in an ASGI app.

So you could have, I don't know, um a dataset application running alongside your um Django application, and you could serve those from the same front end.

They just sit next to each other, or you can wrap your um your existing Django application in a NASGI middleware and then serve that via an ASGI server.

All kinds of interesting things like that.

So that's the that's the sort of main headline.

Will Vincent

And this will be opt-in, so the default will still be WISCI, or what's the plan on that?

Carlton Gibson

Oh, yeah, you just so you'd um you'd configure and so you yeah, you just you start project is exactly the same.

Um, you know, nothing changes.

You run it with Gunicorn exactly as you always did, and then if you want to, you can um create in a instead of a WSGI file, you can create an ASGI file, and there's docs on how to do that and what you include.

And basically the only difference is instead of get WISGI application or WISGI um you import the WISGI get default application um function which wraps up the Whiskey handler.

You there's the same for an ASGI application which wraps up the AS ASGI handler.

And it's really the only difference at this point.

Will Vincent

And can you do this on an app-by-app basis?

Was that what you were saying?

Carlton Gibson

No.

So that's so that's the main uh Right.

Will Vincent

It's project level, you decide.

Carlton Gibson

Yeah, it's project level.

So the main handler, which it takes incoming requests and returns them back to the server, is either a WISGI handler or an ASGI.

Will Vincent

Right, and you were giving the dataset uh example, which is a Simon Willison project, as if you used ASGI, you could have that be piping into Django um asynchronously, whereas you would need a background worker.

Carlton Gibson

Well, you'd at the moment you'd root that separately.

So you'd you'd have your base ASGI application, and part of that would go you'd send to your existing Django app, and part of that you'd send to data set.

So you'd have them sort of side by side at this stage.

Will Vincent

I imagine we'll do a lot of talking and explaining about this going forward.

Carlton Gibson

This is yeah, we're this is gonna this is almost gonna be every episode for the next two years.

You know, we're gonna talk about ACE.

Will Vincent

Um so before we get more into it, so who do we have to thank for doing the heavy lifting on this?

Because we've had some guests on, but I'd always like to call out names because I feel like most people, there's people in the shadows who do the heavy lifting to make this happen.

Who are the names that come to mind for you?

Carlton Gibson

Yeah, so this it's Andrew Godwin um at this stage.

Like he's he's done all the all the conceptual work on um going into this on channels and then on the um ASGI ref, the um the the imp specification and then the um the sort of core library around ASGI.

Um he's he's created that.

Well, I mean, with other inputs from you know Tom Christie and others, uh you know, so it's not just him, but he's done that and then he's bought he pulled this together at um it seems almost just out of the blue at the DjangoCon Europe sprints in Copenhagen.

Um we went from oh ASGI's gonna come, we're not quite sure when to, oh, there's a pull request, we're implementing.

Will Vincent

Well makes it easier to say what's what's new in 3.0.

It's like, oh, actually there is something async there.

Yeah, yeah, yeah.

Carlton Gibson

Because before it was like, well, we're targeting this, and you know, but Andrew's, you know, he's an absolute superhero and he's done it not all by himself, but largely all by himself.

Will Vincent

Yeah.

Well, the good news is this episode we won't have a lag on it, so we'll be releasing it tomorrow.

So if you see Andrew at DjangoCon US, where you and I will both be starting uh this weekend um or online, please do send him Tom Christie and others a thanks because that they don't get much thanks for the work that they do.

But we all rely on it.

Carlton Gibson

Yeah, and they really are pushing the the whole ecosystem forward here.

So that's super.

Um what can I say?

What else can I say about ASGI?

Um I just say that actual async views, which is kind of where the really the really interesting bit comes, will be 3.1 now, targeting that.

Um, where you'll be able to actually write async, um, these async views, which are super for things like proxying to a third party or collating several endpoints into a single response, or you know, any kind of I.O.

blocking endpoint, you know, where people have to five to five years ago, you'd have gone to Node.js for that.

And now you just don't even you don't even have to go to a different um Python framework, which you have done, say a year ago or 18 months ago, you'll just be able to carry on in Django land as if you know nothing changed.

And so that's a real um that will be a real milestone, that'll be a real step forward.

Will Vincent

So if you put on your projection hat, how do you think this is gonna impact background workers?

You know, salary, Redis.

Um I mean, I know we don't know, but it has the potential to massively disrupt how you would set that up.

Because right now you have to use a background worker to do async-like behavior.

Carlton Gibson

Yeah, um, so I think cues, um in the short run, cues aren't gonna go any away um because they're kind of stable and they're mature and they're tested, whereas this stuff is all new and it's bleeding edge, and so it won't work as smoothly as you want.

But yes, uh in Starlet, for instance, you can already spin up a background um can you

Will Vincent

background say what Starlet is for the listeners?

Carlton Gibson

So oh yeah, so sorry.

So Starlet is Tom Christie's um a async um frame microframework, I guess you call it.

I mean it's a bit more than a lot of it.

Yeah, exactly.

Um and so he's he's done a lot of the the um theoretical work here by laying out Starlet, and it was all from um uh a clean plate, so it's nice and you know, there's no crusty bits because it's it's fresh and it's a lovely little thing, um, and it's super, and it does really show the way forward.

And so he gave a talk at um DjangoCon Europe um about a possible redesign of Django, where basically he was talking about Starlet and what he's been doing with um you know an ORM there

Will Vincent

and yeah, we've linked to that before, but we'll definitely link to that again because it's a fantastic, like 50-minute talk, and he explains yeah, async as well as anyone I've seen.

Carlton Gibson

What's going on with AG

Will Vincent

actually same with

Carlton Gibson

what's going on with the ASGI and

Will Vincent

yeah, and I actually uh same with Andrew Godwin, his talk at um PyCon Australia or DjangoCon Australia, he also lays out the plans for async.

So we'll link to those two.

Carlton Gibson

Yeah, and I I think he's got uh his talk at DjangoCon coming up next week.

I think he's on this same topic as well.

I think it's all but like the thing with Tom's talk is it was about Starlet, but it was supposed to be about a Django redesign.

Carlton Gibson

But it's exactly how Django is going to end up.

You know, it's gonna look very similar to the code that Tom's demonstrating there, and it's it's much easier to show it with actual code than it is to wave your hands and say, here's some ideas.

Will Vincent

Right.

Um well and this async stuff is uh really exciting for Django because I I get questions all the time about you know Django versus some other framework.

And we've talked in our episode, um, we've talked about Flask.

You know, Flask is uh intrinsically tied to WISGE.

Um so it will be interesting to see how it handles async.

We'd love to get one of the um big poopas of Flask to come on and talk about that.

But also uh Ruby on Rails, we're gonna have David Hennemier Hansen on next week.

And I don't believe that Ruby is async or that Rails is.

Um so that'd be an interesting question for him.

How are they thinking about that?

Uh I'm sure he'll have opinions.

Um, but this is something in terms of why Django.

It's another feather in the cap of, you know, it's not mature yet, but it will be, and it means that Python has, you know, the ability to do all these node-like features that right now, as you said, people say, Oh, you've got to use node for this.

Carlton Gibson

Yeah, yeah.

You shouldn't you shouldn't have to change your language just because you need higher throughput.

I mean, sure, in there will always be some kind of really tight embedded situation where Python is not the language of choice, right?

But that shouldn't be the 90% case.

That should be the you know the the one in a thousand, one in ten thousand case, not you know, ten percent of cases where I've got to change framework language.

So you don't want to have to change language, and async IO really brings that, um enables you to stay in Python.

And then with Django being as it is, you shouldn't have to change web framework just to do these.

Will Vincent

Yeah, no, it's it's it's

Carlton Gibson

you know, I need a higher throughput endpoint.

You shouldn't have to change your web framework for that.

So you won't have to, and that's for me is really super.

But we didn't finish talking about background tasks.

So install it, you can already spin up a lightweight background task.

Okay.

Um and yeah, I think we'll bring that in, and then that will that's not gonna be a full queuing solution.

You're always gonna need you know, something more robust, but which may be built on top of async, but you're gonna as you scale up, you're always gonna need something more substantial.

But for I want to send an email, I want to render a PDF, though those kind of basic tasks, web web out of out of request response web 101, you'll be able to just do in the framework, you know, spinning up a background task.

That that's on the roadmap, but that's how it's gonna be.

That's you know,

Will Vincent

no, it's it's really exciting.

Looking into the crystal wall.

Will Vincent

So what is there any other major 3.0 features?

I mean, that's a pretty big one.

Oh yeah, yeah, yeah, yeah.

Carlton Gibson

So the other one, um, other big one is Maria DB compatibility.

So up until now we've um supported um SQLite, SQL Lite, uh, Postgres, MySQL and Oracle.

And the the MySQL fork, open source fork is MariaDB.

And whilst that's kind of has there are compatibility diff differences, and so it's kind of been compatible, but not quite.

And that out from 3.0, it's officially supported, and so all database features will you know get the same love and work and attention that they we give to all the backgrounds.

Will Vincent

Right.

Well, in our uh chat with Adam Johnson, he talked at length about Maria DB, MySQL, and um so folks want to learn more about that.

Carlton Gibson

Yeah, so if you're in the if you're in the MySQL world, then MariaDB is the way to go, I think.

Now it's the o it's the open source um option.

And um it's I think it's pace if I'm correct, it's it's pace pace of development, it's faster, and you know, it's where you want to be, it's where all the mind share is.

Will Vincent

So what about um features that just missed?

Because I saw there was some talk on uh JSON field.

Well, hang on,

Carlton Gibson

hang on, hang on before we you know, no, no, because my other favorite one is that um so this is these are my sort of top three, is um enums for choices for um model fields.

Oh so um you've been you know you've always been able to so string field, you've always the the example is um school years, right?

So you've been in freshman, sophomore, CPU.

Will Vincent

That is the canonical idea.

Carlton Gibson

You've always diff right well that's from the docs, right?

So you've been able to define that using strings, and that's all very well and good, but what you really wanted to always use was an enum, which is a a a constricted list of specific values, right?

So that you know, in in other and it's something that Python didn't have with enums, and then I don't know, three point something or other enums came in, but they weren't particularly user-friendly in that you couldn't you had to compare, for instance, the enum value with the enum value.

You couldn't compare it with a string and get the right kind of result.

The natural API usage wasn't very good.

And so there was anyway, that's all been worked around, and you can now use for your model choices choices, you can use an actual enum, and the nice comparison APIs that you want are all been implemented, so it works, it works how you want.

So that's a really good feature.

I think for most users, that's actually the the m most significant feature in the you know the HDI stuff.

Will Vincent

But if you've done anything with choice fields, that's a that's a really big one.

Carlton Gibson

I mean, didn't anyone use Django braces and it it put in a um had a choices thing which tried to embed it?

Yeah, yeah.

And that was great, but then you got sort of caught in this.

Oh, I've been I've used this Django braces field, and I can't quite work out how to escape from that because it was it it added this whole um scaffolding around choices.

Well, use an enum.

An enum is the is almost always going to be the natural and you there's um there's enums um special subclasses for string types.

So you know, if you want a um freshman, sophomore, senior type enum, there's special class for that.

Or if you want integers, there's special classes for that.

So, you know, one, two, three, four might be your choices.

Um, or you can create a subclass for your own field type, you know.

Yeah, you I don't know what you might put in there because those are the obvious ones.

But if you could for for most users, that's that's just a an awesome addition.

Will Vincent

Yeah, and who so who do we have to thank?

Again, I would I always like to call out for both both for MariaDB and then for the Enam.

Who's who's been leading the charge developmentally?

Carlton Gibson

Well, Shay and Nick Pope are the big ones that have been doing it.

Um they uh yeah, to Nick pushed that over the line finally.

Uh that took a lot of work.

It was because there was there was some debates on the the mailing list about how it couldn't be this way and it couldn't be that way, and uh there was a bit of pushback.

Uh so that it's in is is awesome and credit to

Will Vincent

So three major features for 3.0.

There's some symmetry there.

Yeah.

Um oh well speaking of the docs too, I I wanted to um separate from the Google developers list, um, because there's also the uh Django Users Google group, which I think most people can agree the format is maybe not ideal.

Uh I think Andrew Godwin launched a discourse page that's on, I think um, we'll link to it.

I think it's forums.jjango

Carlton Gibson

with Marcus and Tobias.

Will Vincent

Yeah, a bunch of people.

But yeah, I'll link that and I want to

Florian was involved.

Will Vincent

Be pushing that because I think that's a really welcome addition to the community.

Carlton Gibson

Um that's a discourse forum, right?

With discourse being a back end software.

Will Vincent

Yeah, and that's it, and that's something I've thought about just doing for a long time because there isn't a great user-friendly place where kind of everyone hangs out to answer questions from users.

Carlton Gibson

Um Yeah, and I think that's the thing.

Everyone hangs out.

Carlton Gibson

I mean, so you know, you or I might start a forum, but it's just uh, you know, it's just a forum on our website.

We know, but because it's you know, forum.jjangoproject.com, hopefully we can get the critical mass needed to make that into a welcoming and definitive location to get support.

Will Vincent

Exactly.

And yeah, and we'll I'll put the link, but it is I I typed in forums.jjango project.com.

It wasn't working.

I was like, what's going on?

But it's forum.

Carlton Gibson

So uh we should probably get a redirect on that.

Will Vincent

So that's exciting news too.

So uh oh, so I'd um so 3.1.

So maybe uh JSON fields or

Carlton Gibson

yeah, so that's that was um a Google Summer of Um project, uh summer of code project that went on over the summer, and it's so nearly ready.

Um, but it was just coming in too hot.

So Sage, whose last name escapes me momentarily, um did that and he's done a brilliant job.

And it will be, you know, it needs another going over, a couple of months more, and it will be merged in, and that will be 3.1.

But what that gives us is um JSON field for all the supported DBs, including Maria DB.

Wow, yeah.

Um, and so that's that's just awesome.

Like, so for me, one of the I not always use JSON field, but I use JSON field a lot.

And what that has meant for the last few years is that even just spinning up a um a test project, a but an idea on my laptop when I'm just playing around, I've had to um spin up Postgres.

Now I've always got Postgres spinned up, but it's just that one extra hurdle.

Well, what I really want is to just use SQLite.

I really like SQLite.

I just want to use that, and I want to use that until the point at which I've got concurrent rights, in which case then I'll you know think about switching.

And I haven't been able to do that.

Um you can.

Will Vincent

Or you will be able to do that.

Carlton Gibson

With the JSON, with the built-in JSON field, I'll be able to do that.

And I think that would be super because people will be able to explore JSON field without this whole extra step of spinning up a separate um.

Will Vincent

Right, which there is, I mean, I'm thinking of this in the context of um my talk at DjangoCon is gonna be on search, and we're gonna do an episode on that.

But to use Postgres's built-in full text search, which is uh built into Django, you have to spin up Postgres.

And that's not an easy task, and there isn't um you know, I'll show a way to do it.

Um I I like doing it with Docker, uh, and I show in chapter two of Django for Professionals, my new book.

You can um read that for free online.

But um there's a lot of different ways to do it, and it's a big hurdle.

Even for me, just going through the examples, thinking of the talk, I was just like, oh God, I gotta like, you know, escape SQLite, start project land, and you know, make it a little more real.

So um it's really nice not to have that hurdle to play with the fields.

Carlton Gibson

Yeah, but I mean, just out of interest, there's full text search support in uh um SQLite too, right?

Will Vincent

So But not built

Carlton Gibson

into that working.

Um I mean Simon Wittison has done amazing stuff with search on um.

Will Vincent

Yes, he has doing why

Carlton Gibson

aren't we robbing all of that and putting that into Django?

Will Vincent

Maybe yeah, we we we can ask him at um at DjangoCon.

Yeah, he's he's started his fellowship at Stanford.

Um so okay, so what uh anything else?

That was the high point.

I wanted to, you know, these releases come out.

It's the version numbers is really scary to beginners, and in practice, it's you know, Django's quite mature.

There aren't pre are there any breaking changes?

That's actually a good question.

I know there'll be a full write-up of the thing.

Carlton Gibson

Yeah, there's a list, but they're nothing like it's not like when we changed the middleware for 1.10 or something like that.

Which even that wasn't a big change.

You just had to, you know, change the middleware classes to middleware in the settings, and you had three versions in order to do that, so it wasn't the end of the world.

But like um there were there aren't any big structural changes like that is what I'm saying.

Will Vincent

Right.

And we'll we'll do a full episode and I'll probably write some tutorials in December when it launches live.

But for now, if you're listening, please do go get the alpha, try it out.

Carlton Gibson

Yeah, if you've got continuous integration and you could run an extra build on your continuous integration with the alpha, then that would be amazing because that tells us either that we did break something, in which case we can fix it before um the final release, or it's equally important, it tells us that we didn't.

And you know.

Will Vincent

Yeah, that's a win either way.

All right, great.

Well, this is um a shorter one.

We want to do some more shorter ones instead of the lengthier ones we've been doing recently.

So yeah, if you want to give us feedback, we're at Chat Django on Twitter, and all the episodes are at DjangoChat.com, and we have a new newsletter.

So if you prefer to get an email telling you about what's happening, there's a link to do that uh on the website as well.

So we'll uh I'll talk to you next time, Carlton.

Carlton Gibson

All right, take care.

Join us next time.

Bye bye.