47 - ModelForm in Depth - Customising Fields and Methods - Django | DRF | React w. Data Analysis

Опубликовано: 27 Февраль 2026
на канале: Sugarloaf And a Cup of Joe
354
8

Useful links:
https://docs.djangoproject.com/en/3.2...

About this video:
Just like Class Based Views, Django provides us with Form Classes that abstract a lot of repetitive work when it comes to form handling. And also like CBVs, Form Classes have standardised fields and methods that can be customised to our needs.

Video Content:
00:00 Intro
00:12 Add comment_char and comment_text to Income model

01:19 Customising fields - start
03:17 How fields are generated by Django?
07:19 initial - set default value
08:01 Add date picker widget to DateField
08:19 Set initial date in DateField to now
08:47 Set initial choice in ChoiceField
10:34 Set max_length to limit CharField
11:07 Set required to make HTML field required or not
12:13 Add Textarea widget to CharField
12:38 Add HTTP attributes
14:09 Add help_text
14:14 Change label

14:40 ModelForm methods - start
15:32 is_valid - for validation
18:37 clean_field_name - for standardising particular field
21:34 clean - to standardise all fields in one place
22:53 save - to catch the moment before saving to database

24:44 Final cleanup in code and database
26:23 Summary


About this tutorial:
The primary goal of this tutorial is to take you through the steps of creating a solid Django portfolio project that will stand out when you talk to your future employer.
Check out tutorial's intro to see if it's something for you:
   • 01 - Introduction to the course - Django -...  

Tutorial repo:
https://github.com/SugarloafAndACupOf...

Please hit SUBSCRIBE if you wanna get the notifications about the new content!
Also, like the hell out of this video if you find it useful/interesting!
Follow us on Facebook:   / sugarloaf-and-a-cup-of-joe-101638761829670  
and Instagram:   / sugarloaf_and_a_cup_of_joe