Pydantic Introduction - Models, Fields, Constrained Types, Validator Functions and Model Exports

preview_player
Показать описание
In this video, we dive into the Pydantic library in Python. This is based on the following blog post:

We'll learn a number of things, including:

1. How to define Pydantic model classes and fields with type-annotations.
2. How to define Optional fields and constrained fields
3. How to work with complex Python types such as UUID, Enum and date objects
4. How to define a custom validator function for a field on the model
5. How to export models to JSON and Python dictionaries

📌 𝗖𝗵𝗮𝗽𝘁𝗲𝗿𝘀:
00:00 Intro
01:13 Analysis of the structure of the data to model
02:47 Installing Pydantic and Requests packages
04:02 Defining Pydantic model class
06:22 Creating Optional fields on the Pydantic model
11:09 Constrained fields in Pydantic
15:23 Using custom validator functions in Pydantic
19:54 Using Enums as types in Pydantic models
22:22 Exporting Pydantic models to dictionaries and JSON

☕️ 𝗕𝘂𝘆 𝗺𝗲 𝗮 𝗰𝗼𝗳𝗳𝗲𝗲:
To support the channel and encourage new videos, please consider buying me a coffee here:

▶️ Full Playlist:

𝗦𝗼𝗰𝗶𝗮𝗹 𝗠𝗲𝗱𝗶𝗮:

📚 𝗙𝘂𝗿𝘁𝗵𝗲𝗿 𝗿𝗲𝗮𝗱𝗶𝗻𝗴 𝗮𝗻𝗱 𝗶𝗻𝗳𝗼𝗿𝗺𝗮𝘁𝗶𝗼𝗻:

#python #pydantic #datascience
Рекомендации по теме
Комментарии
Автор

Awesome introduction to Pydantic. Will be grateful if you plan a video for Pydantic V2

chitreddysairam
Автор

Btw, a way to display the JSON response in a much more readable way is to use the 'pprint()' function from the pprint module. Simply using pprint(response.json()) rather than print(response.json()) will give you a more legible rendering of your json response.
I find it super helpful when parsing through deeply nested JSON.

RedShipsofSpainAgain
Автор

Great video, perfect timing, working on a Django-Ninja project. Really look forward to your content.

robhafemeister
Автор

You are an absolute legend. Truly, between this and your playlists on Django/HTMX, you have saved me from many a headache. Cheers, man.

Profutbol
Автор

That's a great video. I code with javascript and I wanna learn python for web. 👍

diegosantosmoto
Автор

This is a great video. Thank you very much. Im working on a project using pydantic library.

mercy.yerram
Автор

My new favorite Python channel. Job well done !

je
Автор

I really look forward to your videos. Thanks a lot

swelanauguste
Автор

This is awesome. You make me love Python more than usual. Much obliged.

ekkalukeksook
Автор

Your tutorial save me from several headaches. Thanks for this I appreciate it 😎

joaquingonzalez
Автор

Excellent, thanks !
Please, could you show how use websockets with HTMX and FastAPI ???

ProfeDuilio
Автор

When BaseModel is implemented in the same file, it works. But, if you define BaseModel in different file and import it, it raises Redundant Cyclic UHE

rolandovillcaarias
Автор

Do you think it's a good idea to use Models, Fields and Constrained Types for an ETL (extract, transform and load) process in Data Engineering?

ProfeDuilio
Автор

Sir make a video on django sub query please

SOHAILKHAN-iufu
Автор

A lot of this functionality is already in Django, which you have videos on. Why use Pydantic when Django has this built in?

skyhappy