Web Forms With WTF! - Flask Fridays #5

  Рет қаралды 65,982

Codemy.com

Codemy.com

Күн бұрын

In this video we'll start to use Web Forms for our Flask project with WTF (What the Forms!).
Web forms with WTF are incredibly easy to use and come with all sorts of features that we need like form validation, CSRF token creation, and even reCAPTCHA.
You can always build out web forms by hand, but using a 3rd party system like WTF just makes it so much easier!
In this video we'll look at FlaskForm, StringField, SubmitField, and the DataRequired validator.
Timecodes
0:00​ - Intro
1:36 - Pip Install flask-wtf
2:04 - Import WTF
4:37 - Create A Secret Key
6:11 - Create a Form Class
7:45 - Create name.html Webpage
8:24 - Create Route and Function For name.html
12:12 - Add Link to name.html in Navbar
12:47 - Add Form To name.html Webpage
16:14 - Add Bootstrap To Form
18:23 - Change Button Color
19:33 - List of WTF Fields and Validators
21:33 - Check out the WTF Documentation
22:02 - Conclusion

Пікірлер: 108
@Codemycom
@Codemycom 3 жыл бұрын
▶️ Watch Entire Flask Friday Playlist ✅ Subscribe To My KZfaq Channel: bit.ly/3ig2eJn bit.ly/2IGzvOR ▶️ See More At: ✅ Join My Facebook Group: Codemy.com bit.ly/2GFmOBz ▶️ Learn to Code at Codemy.com ✅ Buy a Codemy T-Shirt! Take $30 off with coupon code: youtube1 bit.ly/2VC9WUN ▶️ Get The Code bit.ly/2L1jBl5
@rauldinho
@rauldinho 3 жыл бұрын
I'm a simple man. I see a new Codemy video, I like, watch, learn and practice. lol
@Codemycom
@Codemycom 3 жыл бұрын
You rock!
@tradingoptions
@tradingoptions 10 ай бұрын
2023: [Bug Fix] You need to add {{ form.csrf_token }} before or after this line {{ form.hidden_tag() }} on the name.html page. Else if form.validate_on_submit() == False This is a great series of videos. Thanks!
@francislachapelle123
@francislachapelle123 3 жыл бұрын
Just started Flask at my job for a project, and your videos are clear and very instructives. Good job man.
@Codemycom
@Codemycom 3 жыл бұрын
Glad I could help!
@imnotaburrito9365
@imnotaburrito9365 4 ай бұрын
finally after 5 videos someone that explains everything clearly!
@Codemycom
@Codemycom 4 ай бұрын
Glad you liked it!
@articulation7
@articulation7 2 жыл бұрын
What a series of the videos! Thanks for that amount of work! Very cool Cheers
@Codemycom
@Codemycom 2 жыл бұрын
Glad you enjoyed it!
@UGLi
@UGLi 2 жыл бұрын
Hi, I LOVE your tutorials, they are 100% on point. I'll keep on studying them with pleasure. Just a note : at 7:02, you say DataRequired() is a function, it seems to be an instance of the DataRequired class. It's only a detail but before running the code without the (), and reading the traceback, I was a bit lost :).
@rchocano
@rchocano 2 жыл бұрын
Great video, very good explanation. Thank you!
@Codemycom
@Codemycom 2 жыл бұрын
Thanks!
@lukagajinov232
@lukagajinov232 Жыл бұрын
Great video, very good and quick explanation. Thanks!
@Codemycom
@Codemycom Жыл бұрын
Glad you enjoyed it!
@pmatoss
@pmatoss 9 ай бұрын
I have no words to describe my gratitude for this series of videos. In addition to being extremely educational and educational, they are so realistic that I am applying them to an educational project that I am developing with a group of friends. Thank you very much for the great work. Greetings from Brazil.
@Codemycom
@Codemycom 9 ай бұрын
You're very welcome!
@alicherifi9075
@alicherifi9075 3 жыл бұрын
Best Fridays, are Flask Fridays
@Codemycom
@Codemycom 3 жыл бұрын
Yes!
@david2358
@david2358 Жыл бұрын
excellent video, just subscribed!!!
@Codemycom
@Codemycom Жыл бұрын
Awesome!
@hiwab41
@hiwab41 3 жыл бұрын
I like before seeing your vids! Because i know it gonna be so good -:)
@Codemycom
@Codemycom 3 жыл бұрын
Wow, thanks!
@sachinsinghal13
@sachinsinghal13 3 жыл бұрын
Me too
@ahmadfaisal6356
@ahmadfaisal6356 2 жыл бұрын
I'm too
@mehboob_pythonist
@mehboob_pythonist 10 ай бұрын
Amazing lecture sir... Please keep uploading new updated videos on flask. you sre the best mentor
@Codemycom
@Codemycom 10 ай бұрын
There are many more flask videos in this playlist
@demasjaring5435
@demasjaring5435 3 жыл бұрын
verry nice explaination ,thx!
@Codemycom
@Codemycom 3 жыл бұрын
Glad it was helpful!
@radiagulzan
@radiagulzan 2 жыл бұрын
Hey, thank you for the videos! I had the same problem as Patrick. The page doesn't follow the IF condition so doesn't respond back despite reloading. Do you have any idea why this might be happening?
@GIULI4994
@GIULI4994 11 ай бұрын
very good tutorial, thanks
@Codemycom
@Codemycom 11 ай бұрын
Welcome
@nerminqulu
@nerminqulu Жыл бұрын
I like you are smile everytime when you saying WTF
@Codemycom
@Codemycom Жыл бұрын
haha
@expressionamidstcacophony390
@expressionamidstcacophony390 7 ай бұрын
This is one of those cases where youtube videos are more helpful documentation than the actual documentation. Dear oh dear.
@Codemycom
@Codemycom 7 ай бұрын
Glad you enjoyed it!
@likbezlik
@likbezlik 6 ай бұрын
I looked at many Flask tutorials and yours is the only one that helped me find a solution to this simple form. Took me a few hours to fix some bugs though. I was very confused with the attributes that we have to pass to the render_template "name=name" and "form=form". What exactly does this part do in the code?
@Codemycom
@Codemycom 6 ай бұрын
passes the name and the form
@asce313
@asce313 3 жыл бұрын
👍 🔥🔥
@Codemycom
@Codemycom 3 жыл бұрын
:-)
@Darkev77
@Darkev77 Жыл бұрын
As usual, clear and concise. Anyone know why I should use wtforms over typical html input tags with specified types (email, password, etc.) and properties (required, title, etc.)?
@AwesomelyAwesomeKidd
@AwesomelyAwesomeKidd Жыл бұрын
He explains alittle in the start, basically because you can use wtforms for uploading files and images
@SZGSports
@SZGSports Жыл бұрын
If I wanted to pre populate the form, how would I pass the string?
@koslockwood
@koslockwood 2 жыл бұрын
Can you recommend any resources on more complex form use? I'd like to better understand passing data back to the python script and ideally creating dynamic forms: essentially my goal is to have a list of objects pulled from a database via API (i've got this working) have the list of objects printed as selectable items in a form, and have the form return a list of objects that were selected for additional processing to be done against.
@Codemycom
@Codemycom 2 жыл бұрын
I have lots of videos on forms...but there really isn't much more to them.
@andrewsweeney1653
@andrewsweeney1653 2 жыл бұрын
Is there a tutorial for adding 1. Date time picker to the form? 2. Multi select dropdowns?
@Codemycom
@Codemycom 2 жыл бұрын
I don't think so, but you could have checked the playlist faster than it took to ask :-p
@stephontidd7051
@stephontidd7051 10 ай бұрын
cant get bootstrap to reflect changes in name.html EX: {{ form.name.label( class = "form-label" ) }} doesnt change the look
@BenMrMakinesiyim
@BenMrMakinesiyim 3 ай бұрын
aaaaahhh it's a hard framework to learn. Soooo many methods and references in there. But thank you anyways for every detail.
@Codemycom
@Codemycom 3 ай бұрын
Yeah definitely a little harder than Django
@seacook42
@seacook42 Жыл бұрын
Hi John, I've just come back to Flask Fridays and find that this segment is outdated. FlaskForm is no longer supported by wtf. Any chance of an update for this segment?
@Codemycom
@Codemycom Жыл бұрын
Of course it's still supported...why would you think that it wasn't?
@gtasawstudio5010
@gtasawstudio5010 3 жыл бұрын
Good. I very like you ;)
@Codemycom
@Codemycom 3 жыл бұрын
Thanks! 😃
@salmantas2335
@salmantas2335 10 ай бұрын
in case of is there any one wondering how to change button text other than submit: just pass what you want into the SubmitField that you created in your class. for example: submit = SubmitField('sometext')
@marymozaffari2963
@marymozaffari2963 Жыл бұрын
Hi John in 16:19 my code has problem with submit button did you change the code when you run it?
@Codemycom
@Codemycom Жыл бұрын
Did I change the code? You see exactly what I do in the video.
@marymozaffari2963
@marymozaffari2963 Жыл бұрын
Thank you for reply exactly you didn't and I was studying your code step by step but when I want to run it, It has problem with submit button here is the error: jinja2.exceptions.UndefinedError: '__main__.NamerForm object' has no attribute 'submit'
@Codemycom
@Codemycom Жыл бұрын
@@marymozaffari2963 You'll have to rewatch the video and retrace your steps to see what you did wrong.
@abdullahhazari918
@abdullahhazari918 3 жыл бұрын
I love you men !
@Codemycom
@Codemycom 3 жыл бұрын
Thanks!
@danielruzicka3858
@danielruzicka3858 Жыл бұрын
is it possible to do the python logic not in the html file but in already in the backed python file ?
@Codemycom
@Codemycom Жыл бұрын
Sure, you can use python however you want on the backend.
@Yanis0071
@Yanis0071 3 жыл бұрын
Hello ! How can we prevent duplicate form submissions using the POST?
@Codemycom
@Codemycom 3 жыл бұрын
It does it by default. If someone hit's reload they are prompted by a form re-submission popup
@wirrexx
@wirrexx 4 ай бұрын
Love what you are doing. However, I got an error pip install flask-wtf on windows. as It continue to say that the module is missing. However, I can see it in my requirements on pip freeze. Confusing
@Codemycom
@Codemycom 4 ай бұрын
If it's listed in the requirements, than it's installed. If some module is missing, pip install that module.
@wirrexx
@wirrexx 4 ай бұрын
@@Codemycom fixed it. I had to build a new system In sublime and make sure that the path was in my virtual environment python.exe
@patmower46
@patmower46 2 жыл бұрын
John, I must've missed something. Everything works with one exception: When I put a name in the name page, press submit, the name goes away, but the page and name are NOT redisplayed. I know I have missed something....but what?!
@Codemycom
@Codemycom 2 жыл бұрын
I couldn't guess...rewatch the videos and try again :-)
@source_thought
@source_thought 2 жыл бұрын
Same here
@brianbwoma9947
@brianbwoma9947 2 жыл бұрын
@@source_thought i think its something to do with the crsf token
@radiagulzan
@radiagulzan 2 жыл бұрын
same!
@radiagulzan
@radiagulzan 2 жыл бұрын
could you solve it? I rewatched and did everything but it is still unresponsive
@MagicByIzzy
@MagicByIzzy 3 жыл бұрын
Hi John i love your videos! Can you please do a video on pymongo and flask especially on storing images in a mongo db database?
@Codemycom
@Codemycom 3 жыл бұрын
Yeah I might get to that in the future
@MagicByIzzy
@MagicByIzzy 3 жыл бұрын
@@Codemycom i would really appreciate that! Thanks
@devansh8095
@devansh8095 3 жыл бұрын
Sir is it bad to convert kivy file into exe with pyinstaller?
@Codemycom
@Codemycom 3 жыл бұрын
Maybe you should ask that question under the video I did in the kivy playlist showing how to convert a kivy file into exe with pyinstaller...
@devansh8095
@devansh8095 3 жыл бұрын
@@Codemycom yes sir that's make sense but now my doubt is clr
@jamikemichelohia2615
@jamikemichelohia2615 3 жыл бұрын
Just came to check WTF wasnt what i thought it was. Jokes aside. great Job
@Codemycom
@Codemycom 3 жыл бұрын
Haha
@paulbrugger9610
@paulbrugger9610 Жыл бұрын
When you install new packages make sure you are in the virtual environment and not in another terminal that is not in the ve.
@Codemycom
@Codemycom Жыл бұрын
Yep
@alexi2706
@alexi2706 Жыл бұрын
I am getting 'tuple' object is not callable
@Codemycom
@Codemycom Жыл бұрын
What did you do differently from the video?
@denisgarden1
@denisgarden1 2 жыл бұрын
Where can find the code?
@Codemycom
@Codemycom 2 жыл бұрын
in the pinned comment, like I said in the video.
@orick08
@orick08 Ай бұрын
When I submit the form I get the 404 error page
@orick08
@orick08 Ай бұрын
I had action="POST" instead of method="POST" on the form, careful with the VSCode
@Codemycom
@Codemycom Ай бұрын
@@orick08 glad you got it sorted out
@deki90to
@deki90to 3 жыл бұрын
Well this is where I lost myself :0 I'll stick with django
@Codemycom
@Codemycom 3 жыл бұрын
Django is always a nice option
@hamayoonyousafi555ATgmail
@hamayoonyousafi555ATgmail 2 жыл бұрын
How did you manage saying WHAT THE FORMS every time! not accidentally saying WHAT THE FXCK haha
@Codemycom
@Codemycom 2 жыл бұрын
Wasn't easy...and you know...video editing is your friend ;-)
@akgang602
@akgang602 3 жыл бұрын
First
@Codemycom
@Codemycom 3 жыл бұрын
Nice!
@akgang602
@akgang602 3 жыл бұрын
@@Codemycom thanks for heart 😁
@oleksandrshuhurov7536
@oleksandrshuhurov7536 5 ай бұрын
SECRET KEY = "f off" From all the deaf listeners / watchers
@allanimeworld2898
@allanimeworld2898 3 жыл бұрын
Sir please make a series on pygame its very demanded sir please🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏
@Codemycom
@Codemycom 3 жыл бұрын
I probably will at some point
@allanimeworld2898
@allanimeworld2898 3 жыл бұрын
@@Codemycom thanks sir for confirmation stay tuned with you👌👌👌👍👍
@hiroshi_kamisatou
@hiroshi_kamisatou Жыл бұрын
What the fuck module
@aditya.21
@aditya.21 Жыл бұрын
Could anyone help me to hide the secret key using .gitignore , it happens somewhere around @ 6:00 in the video
How To Use Messages With Flask - Flask Fridays #6
10:43
Codemy.com
Рет қаралды 32 М.
How to Use Databases With SQLAlchemy  - Flask Fridays #8
25:36
Codemy.com
Рет қаралды 90 М.
THE POLICE TAKES ME! feat @PANDAGIRLOFFICIAL #shorts
00:31
PANDA BOI
Рет қаралды 13 МЛН
Дибала против вратаря Легенды
00:33
Mr. Oleynik
Рет қаралды 4,3 МЛН
Osman Kalyoncu Sonu Üzücü Saddest Videos Dream Engine 170 #shorts
00:27
Was ist im Eis versteckt? 🧊 Coole Winter-Gadgets von Amazon
00:37
SMOL German
Рет қаралды 25 МЛН
Templates, Bootstrap Navbars, and Links - Flask Fridays #4
16:25
Create a Dependent Select Field With Flask-WTF and HTMX
14:25
Pretty Printed
Рет қаралды 7 М.
Learn HTML Forms In 25 Minutes
24:56
Web Dev Simplified
Рет қаралды 954 М.
Before You Install Flask...Watch This!  Flask Fridays #1
21:00
Codemy.com
Рет қаралды 119 М.
How to Upload Files with Flask Using Python
11:04
Arpan Neupane
Рет қаралды 67 М.
Top 10 CSS One Liners That Will Blow Your Mind
13:34
developedbyed
Рет қаралды 915 М.
How To Use Docker To Make Local Development A Breeze
21:53
ArjanCodes
Рет қаралды 299 М.
4 Tips for Building a Production-Ready FastAPI Backend
27:02
ArjanCodes
Рет қаралды 52 М.
Create One To Many Database Relationship  - Flask Fridays #28
13:27
THE POLICE TAKES ME! feat @PANDAGIRLOFFICIAL #shorts
00:31
PANDA BOI
Рет қаралды 13 МЛН