Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
85 changes: 32 additions & 53 deletions transcripts/490-django-ninja.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

00:00:11 Django Ninja is highly inspired by FastAPI, but also deeply integrated into Django itself.

00:00:17 We have Vitaly Kucherev, the creator of Django Ninja, on the show to tell us all about it.
00:00:17 We have Vitaliy Kucheryaviy, the creator of Django Ninja, on the show to tell us all about it.

00:00:22 This is Talk Python to Me, episode 490, recorded December 10th, 2024.

Expand Down Expand Up @@ -144,7 +144,7 @@

00:03:04 Yeah.

00:03:04 So my name is Vitaly Kucherawe.
00:03:04 So my name is Vitaliy Kucheryaviy.

00:03:06 Yeah.

Expand Down Expand Up @@ -346,21 +346,21 @@

00:10:09 And yeah, that's, that's how, how it born.

00:10:11 And I guess the next part is like actually why it exists is like, yeah, so in PyDentic, there is model word is reserved for like, you know, any kind of validation.
00:10:11 And I guess the next part is like actually why it exists is like, yeah, so in Pydantic, there is model word is reserved for like, you know, any kind of validation.

00:10:20 Yeah.

00:10:21 So PyDentic uses word model for validation, but in Django world model means like tables, yeah, database tables.
00:10:21 So Pydantic uses word model for validation, but in Django world model means like tables, yeah, database tables.

00:10:29 So you cannot just bring PyDentic models.
00:10:29 So you cannot just bring Pydantic models.

00:10:31 It's the ORM, yeah.

00:10:31 Yeah.

00:10:32 And because people will be confused when you, okay, you speak about model and then you kind of need to think, okay, is it database or is schema?

00:10:39 So like for me, the main goal was to introduce class called schema, which is like a PyDentic model under the hood.
00:10:39 So like for me, the main goal was to introduce class called schema, which is like a Pydantic model under the hood.

00:10:46 And then it should like hide as much as possible the word model.

Expand All @@ -382,7 +382,7 @@

00:11:32 It was like really lightweight.

00:11:34 So way faster than Django Ress framework.
00:11:34 So way faster than Django Rest framework.

00:11:36 So I thought, okay, she should be something fast.

Expand Down Expand Up @@ -504,7 +504,7 @@

00:15:39 Create your Sentry account now at talkpython.fm/sentry.

00:15:43 And if you sign up with the code talkpython, all capital, no spaces, it's good for two free months of Sentry's business plan, which will give you up to 20 times as many monthly events as well as other features.
00:15:43 And if you sign up with the code TALKPYTHON, all capital, no spaces, it's good for two free months of Sentry's business plan, which will give you up to 20 times as many monthly events as well as other features.

00:15:55 All right, well, let's dive into Django Ninja.

Expand Down Expand Up @@ -614,7 +614,7 @@

00:19:41 But yeah, so it's, it's, it's really big industry and Django like REST framework has already like lots of plugins or like tools or like, you know, community that you can rely on.

00:19:52 But yeah, again, like the, the, basically, I think the problem that is solved with like this pidentic validation and serialization is like, yeah, you simply rely on like latest standards.
00:19:52 But yeah, again, like the, the, basically, I think the problem that is solved with like this Pydantic validation and serialization is like, yeah, you simply rely on like latest standards.

00:20:04 Yeah, like, so if you never use like type annotation, this is actually first, the good way to try it out and see the benefits.

Expand Down Expand Up @@ -678,7 +678,7 @@

00:22:39 And people want to see the graph.

00:22:41 They can just visit jingo-ninja.dev and it's right there on the homepage.
00:22:41 They can just visit django-ninja.dev and it's right there on the homepage.

00:22:45 But yeah, if you start doing like you start, you know, doing some kind of square roots of some numbers, yeah, you will not get this performance.

Expand All @@ -692,7 +692,7 @@

00:23:01 So I never actually measured like what is the performance.

00:23:04 So yeah, like, but again, it's like probably like you will see the difference with Pydantic 2 when you like really, so you're in, you have inputs of like really bulky Jasons.
00:23:04 So yeah, like, but again, it's like probably like you will see the difference with Pydantic 2 when you like really, so you're in, you have inputs of like really bulky JSON.

00:23:14 Like, you know, let's say you have like, you know, payload that is like one megabyte and you will, you will definitely see performance.

Expand Down Expand Up @@ -806,9 +806,9 @@

00:26:22 There's also like for, I guess for, for the difference for folks who work with FastAPI.

00:26:27 The key difference is that Jenga Ninja, Jenga Ninja's operation, their function, the first argument is always request.
00:26:27 The key difference is that Django- Ninja, Django-Ninja's operation, their function, the first argument is always request.

00:26:35 Because this is like historically what Jenga, what Jenga protocol is.
00:26:35 Because this is like historically what Django, what Django protocol is.

00:26:39 Yeah.

Expand All @@ -824,7 +824,7 @@

00:26:58 And yeah, like there was a suggestion, so let's remove it.

00:27:02 But I think, yeah, we should keep it, we should keep it consistent with, with, with default Jenga view.
00:27:02 But I think, yeah, we should keep it, we should keep it consistent with, with, with default Django view.

00:27:07 And yeah, like, I think that, that, that, that works perfectly.

Expand Down Expand Up @@ -870,13 +870,13 @@

00:28:11 Another, another thing that's really nice, and you hinted at this before, is that it has automatic documentation, very, very similar to FastAPI for what you write without you doing any work, right?

00:28:23 You just go to slash API slash docs, and you get this nice UI, right?
00:28:23 You just go to /API /docs, and you get this nice UI, right?

00:28:27 You don't have any hassle of creating some UIs.

00:28:30 You just, you just have it for free, right?

00:28:32 So you just go to slash API slash docs, and there you have it.
00:28:32 So you just go to /API/docs, and there you have it.

00:28:35 And you can already like, so by default, Django Ninja comes with two, like three doc and a swagger.

Expand Down Expand Up @@ -932,7 +932,7 @@

00:30:40 So you can create like, you know, as, as, as many as possible ninja API instances.

00:30:45 So you can have like slash public API slash private slash custom slash, yeah, whatever, like version one, version two, like, and basically you can define multiple, multiple versions, reuse functions.
00:30:45 So you can have like slash public API/private/custom/, yeah, whatever, like version one, version two, like, and basically you can define multiple, multiple versions, reuse functions.

00:30:57 And then, you know, can continue your work while keeping the old, old, you know, version one, version two code or private public, stuff like that.

Expand Down Expand Up @@ -1042,7 +1042,7 @@

00:34:59 And you pointed out that you can have public and private APIs in this similar way.

00:35:04 And so you could have public APIs, maybe multiple versions of them, but also a separate private API that potentially exposes more more things.
00:35:04 And so you could have public APIs, maybe multiple versions of them, but also a separate private API that potentially exposes more things.

00:35:13 Right.

Expand Down Expand Up @@ -1198,7 +1198,7 @@

00:39:25 Like editor should do that to complete.

00:39:28 My pie should not like scream at you and it should validate under the hood.
00:39:28 MyPy should not like scream at you and it should validate under the hood.

00:39:33 So there's like a pretty, pretty like nasty kind of if typing stuff, annotations.

Expand Down Expand Up @@ -1248,7 +1248,7 @@

00:40:49 combinations.

00:40:49 So if you know, maybe like a Jenga plus Python 3.6 or stuff like that was like really giving
00:40:49 So if you know, maybe like a Django plus Python 3.6 or stuff like that was like really giving

00:40:55 some headaches.

Expand All @@ -1264,9 +1264,9 @@

00:41:22 So your editor works.

00:41:24 If you use MyPi, you really like types, you have 100% type correction.
00:41:24 If you use MyPy, you really like types, you have 100% type correction.

00:41:30 And then on the hood, it does as fast as possible, whatever, like PyDentic Magic,
00:41:30 And then on the hood, it does as fast as possible, whatever, like Pydantic Magic,

00:41:36 media with Rust.

Expand Down Expand Up @@ -1398,7 +1398,7 @@

00:45:29 You know, I have kind of the same feeling about like any, any like Python approaches to the dependency injection libraries,

00:45:36 because I think the, the Pytonic way is actually like, like it's more kind of, because you can import from strings.
00:45:36 because I think the, the Pythonic way is actually like, like it's more kind of, because you can import from strings.

00:45:43 You can, you know, pass kind of any type of arguments and just access them by like the, this quarks.

Expand All @@ -1412,19 +1412,19 @@

00:46:26 Like, okay, like let's do dependence injection or some kind of SSL protocols, like, you know, timeouts and stuff like that.

00:46:33 But they, they really try to like make it as current Pytonic way as possible through like some quarks or like, or, or like, you know, stuff that you, you never, you never know.
00:46:33 But they, they really try to like make it as current Pythonic way as possible through like some quarks or like, or, or like, you know, stuff that you, you never, you never know.

00:46:42 Okay.

00:46:43 What's what's actually injected, but verbally, you know, what, what's, what's going on.
00:46:43 What's actually injected, but verbally, you know, what, what's, what's going on.

00:46:47 Yeah, the quarks and the stargs, quarks, all that stuff is when I see that it's the function signature, I feel like, okay, the, you kind of given up on helping me know what I'm supposed to do here.

00:46:57 The only way to know is to go read the documentation, which not a big fan.

00:47:01 Let's talk about authentication.

00:47:02 So what's the, the Jingo ninja way for authentication here?
00:47:02 So what's the, the Django ninja way for authentication here?

00:47:07 It looks pretty integrated.

Expand Down Expand Up @@ -1452,7 +1452,7 @@

00:47:50 Off inside this function.

00:47:51 You can also access request and like attach your request.user, which is what is in most cases are done.
00:47:51 You can also access request and like attach your request. User, which is what is in most cases are done.

00:47:57 If you like, you have user in your system that is tied to some token or stuff like that, but it's kind of on purpose that yeah.

Expand Down Expand Up @@ -1656,7 +1656,7 @@

00:54:55 Yeah.

00:54:55 Like whatever new version, like I saw this a lot with Pidentic when they, you know, they already like a version two for like a year in a while.
00:54:55 Like whatever new version, like I saw this a lot with Pydantic when they, you know, they already like a version two for like a year in a while.

00:55:04 While if you ask LLM to implement some stuff, they, they still giving you the old, old approaches.

Expand All @@ -1668,7 +1668,7 @@

00:55:30 Yeah.

00:55:31 But if you like listening to this podcast, you can go to LLM.jangoNinja.dev.
00:55:31 But if you like listening to this podcast, you can go to LLM.djangoNinja.dev.

00:55:36 It will, it will, we'll redirect you to some ticket where I will notify when it's ready.

Expand Down Expand Up @@ -1788,7 +1788,7 @@

01:00:11 Try to make it for people to migrate to newer, newer versions easier.

01:00:15 So like, I guess the hardest part was like, you know, between version zero something to 1.0, but yeah, it will, it was like dictated by the fact that, you know, Pidentic moved from one to two.
01:00:15 So like, I guess the hardest part was like, you know, between version zero something to 1.0, but yeah, it will, it was like dictated by the fact that, you know, Pydantic moved from one to two.

01:00:26 So like, there was no way to make it without breaking changes.

Expand Down Expand Up @@ -1832,7 +1832,7 @@

01:02:09 This is like a very first way to try that to do.

01:02:11 To just simply install Manage Jenga and you'll have Jenga in that hood, Ninja under the hood and everything you need all in one, in one file.
01:02:11 To just simply install Manage Django and you'll have Django in that hood, Ninja under the hood and everything you need all in one, in one file.

01:02:18 Cool.

Expand Down Expand Up @@ -1878,7 +1878,7 @@

01:02:57 Just visit talkpython.fm/sentry and get started for free.

01:03:02 And be sure to use the promo code talkpython, all one word.
01:03:02 And be sure to use the promo code TALKPYTHON, all one word.

01:03:06 And this episode is brought to you by Bluehost.

Expand Down Expand Up @@ -1923,24 +1923,3 @@
01:04:07 Now get out there and write some Python code.

01:04:09 write some Python code.

01:04:10 Open arms!

01:04:13 Open arms!

01:04:15 Open arms!

01:04:17 Open arms!

01:04:19 Open arms!

01:04:21 Open arms!

01:04:23 Open arms!

01:04:25 Open arms!

01:04:27 you you Thank you.

01:04:29 Thank you.