Python Flask Tutorial: Full-Featured Web App Part 3 - Forms and User Input

แชร์
ฝัง
  • เผยแพร่เมื่อ 20 ก.ย. 2024
  • In this Python Flask Tutorial, we will be learning how to create forms and accept user input. We will also learn how to validate that user input and notify the user if the input was invalid. Let's get started...
    The code for this series can be found at:
    github.com/Cor...
    ✅ Support My Channel Through Patreon:
    / coreyms
    ✅ Become a Channel Member:
    / @coreyms
    ✅ One-Time Contribution Through PayPal:
    goo.gl/649HFY
    ✅ Cryptocurrency Donations:
    Bitcoin Wallet - 3MPH8oY2EAgbLVy7RBMinwcBntggi7qeG3
    Ethereum Wallet - 0x151649418616068fB46C3598083817101d3bCD33
    Litecoin Wallet - MPvEBY5fxGkmPQgocfJbxP6EmTo5UUXMot
    ✅ Corey's Public Amazon Wishlist
    a.co/inIyro1
    ✅ Equipment I Use and Books I Recommend:
    www.amazon.com...
    ▶️ You Can Find Me On:
    My Website - coreyms.com/
    My Second Channel - / coreymschafer
    Facebook - / coreymschafer
    Twitter - / coreymschafer
    Instagram - / coreymschafer
    #Python #Flask

ความคิดเห็น • 1.1K

  • @SaidKerimov
    @SaidKerimov 6 ปีที่แล้ว +469

    Man, your videos are better than paid online courses. would be happy if you could prepare data science tutorials...

    • @younesboukroun3060
      @younesboukroun3060 5 ปีที่แล้ว +13

      there is option to support dude!! so people who dont have money to pay they can benifits aswell

    • @ahmedsassi4205
      @ahmedsassi4205 4 ปีที่แล้ว

      @@cdishiyam9232
      open the terminal
      pip install flask flash

    • @carlosdruizg
      @carlosdruizg 4 ปีที่แล้ว

      @@cdishiyam9232 If you are in Google Chrome you can open Developer Mode by right click "Inspect" then right click refresh button and select "Empty Cache and Hard Reload", that should work, in the worst case check if you are typing something wrong on the form field, e.g. the username needs 5 characters but you are writing only 3 or 4

    • @annaanna3260
      @annaanna3260 4 ปีที่แล้ว

      @@cdishiyam9232 same problem did you find a solution?

    • @cdishiyam9232
      @cdishiyam9232 4 ปีที่แล้ว

      @@annaanna3260
      just miss spelled something copy his code from GitHub repo it was kinda difficult to find the mistake without both my code and his next to each other that why

  • @1cannon3
    @1cannon3 5 ปีที่แล้ว +511

    2:03 - importing wtforms
    2:15 - HTML forms vs Python for forms
    2:34 - Registration form
    2:39 - Creating first RegistrationForm (This inherits from FlaskForm)
    2:48 - Having different form fields
    2:55 - Adding a username field
    3:00 - A username is a "StringField" (From wtforms)
    3:40 - Including limitations for usernames (or other fields)
    4:08 - Validators
    4:19 - Validators are arguments you pass into your fields
    4:25 - Passing a list of validators
    4:36 - "DataRequired" validator
    4:41 - "wtforms.validators"
    5:03 - "Length" validator
    5:51 - "Email" validator
    6:33 - "Password" field
    7:16 - Password confirmation
    7:27 - "EqualTo" validator for password confirmation
    8:00 - "EqualTo" arguments are the field you want this to be field to be equal to
    8:12 - Submit button
    8:20 - "Submit" field
    8:50 - Creating a login form
    9:35 - Adding a "remember" field, cookie, so browser remembers users
    10:20 - Setting a secret key for your application
    12:15 - Creating routes for registration and login forms
    12:22 - Registration route
    14:08 - Creating templates for registration & login form

    • @dexternepo
      @dexternepo 5 ปีที่แล้ว +4

      Thank you for this!

    • @PhucNguyen-pf3qb
      @PhucNguyen-pf3qb 5 ปีที่แล้ว +3

      make my day

    • @jonathanvillafana5726
      @jonathanvillafana5726 4 ปีที่แล้ว +1

      This is brilliant thank you so much!

    • @kevinlao3690
      @kevinlao3690 4 ปีที่แล้ว +1

      You sir are a gentleman and a scholar

    • @cdishiyam9232
      @cdishiyam9232 4 ปีที่แล้ว +2

      30:41
      followed exactly everything word by word yet am not getting the success flash msg

  • @BitRunner85
    @BitRunner85 4 ปีที่แล้ว +54

    If you don't see the validation in the browser (for example if you don't see the "This field is required." message) then:
    1. Make sure you included "novalidate" attribute on line 4 from register.html so should be
    2. Make sure you typed "for error" and not "for errors" as I did. Took me 20 minutes to realize but now the form validation works correctly.

    • @AdamBerzi
      @AdamBerzi 4 ปีที่แล้ว +3

      omg, thx a lot!! How did you find the "novalidate" solution?

    • @marianoc835
      @marianoc835 3 ปีที่แล้ว +1

      Thank you very much! The novalidate is not even in his code

    • @brooklyninja
      @brooklyninja 2 ปีที่แล้ว +1

      Thank you for the "novalidate" part! That really helps a lot.

    • @khalidsultani1896
      @khalidsultani1896 2 ปีที่แล้ว +1

      thanks for the novalidate i spend more then 3 hours on this.

    • @wspolczynnik_poissona
      @wspolczynnik_poissona ปีที่แล้ว +1

      Thank you a lot! I was getting really frustrated why it didn't work as shown, the "novalidate" fixed it!

  • @girloffthecob
    @girloffthecob ปีที่แล้ว +32

    IF YOU HAVE A PROBLEM RUNNING IT AT 22:18 LIKE I DID, READ THIS!
    I kept getting the message "Exception: Install 'email_validator' for email validation support." To fix this, just run "pip install email-validator" in your terminal. That should fix it.

    • @vijay4462
      @vijay4462 ปีที่แล้ว

      Thanks bro

    • @ButcherTTV
      @ButcherTTV ปีที่แล้ว

      thanks

    • @nohandle759
      @nohandle759 6 หลายเดือนก่อน

      Thank you

    • @janfcht
      @janfcht 6 หลายเดือนก่อน

      Thanks!!

    • @girloffthecob
      @girloffthecob 5 หลายเดือนก่อน

      oh gosh, I regret to inform you but I stopped learning flask soon after this comment haha. It was just a lot for me to learn at once. Unfortunately when it comes to terminal stuff I'm actually horrible and have no clue how it works. Hopefully someone else replies and helps you out! Try commenting on the main thread!@@nittin_codes9359

  • @The_Bri_Cli
    @The_Bri_Cli 2 ปีที่แล้ว +43

    Flask has changed so much since Corey released this 3 years ago. An update would be stellar!

    • @DominicNweze
      @DominicNweze ปีที่แล้ว

      I know right

    • @sialeakauola4852
      @sialeakauola4852 ปีที่แล้ว +4

      aw man ive spent 2 weeks on these videos.

    • @joeldavis7577
      @joeldavis7577 ปีที่แล้ว +1

      @@sialeakauola4852 It's still usable, just not as current as it could be. I guess Corey has personal life stuff going on.

    • @rrestituti
      @rrestituti ปีที่แล้ว +2

      Hi folks. Could anyone exemplify some changes so I could see this tutorial and study the new way of doing It?

    • @likbezlik
      @likbezlik 9 หลายเดือนก่อน

      Not just flask but bootstrap also. Everything is turning out somewhat different for it and I keep trying to override bootstrap css manually.

  • @Hosseinsarpanah
    @Hosseinsarpanah 5 ปีที่แล้ว +66

    36:04 If you're using PyCharm, Select all occurrences like:
    1) *Set multiple cursors* in the editor area: *Alt + Mouse Click* (Option + Mouse Click for Mac OS X). ...
    2) *Select/unselect* the next occurrence: *Alt + J/Shift + Alt +J* (Ctrl + G / Shift + Ctrl +G for Mac OS X)
    3) *Select all* occurrences: *Shift + Ctrl + Alt + J* (Ctrl + Cmd + G for Mac OS X)

    • @alitaha7146
      @alitaha7146 4 ปีที่แล้ว

      I'm using PyCharm but it doesn't want to import flask_wtf although i've installed flask-wtf...Any help?

    • @sefabockun141
      @sefabockun141 4 ปีที่แล้ว

      I am using VScode and it works, thank you :)

    • @marcaidonidis4435
      @marcaidonidis4435 3 ปีที่แล้ว

      Thank you!

    • @aybaws
      @aybaws 2 ปีที่แล้ว

      @@alitaha7146 psych arm probably didn’t inherit the global packages. to fix it, create a new project and check ‘inherit global packages’ .

  • @urbaneplanner
    @urbaneplanner 2 ปีที่แล้ว +11

    another good video - btw following along, I relaized at around 20:00 that you do need to pip install email_validator - I may have missed that instruction in the earlier part of the video

    • @Destide
      @Destide 2 ปีที่แล้ว

      You did not this was exactly what I was stuck on thankyou

    • @mitch6948
      @mitch6948 2 ปีที่แล้ว +1

      That was a god send. Didn't know what was wrong and this helped.

  • @acidspark
    @acidspark 5 ปีที่แล้ว +422

    Around 48:00 when he is talking about using the multi-select functionality he never tells you how to do this. For those that didn't know it existed you select the first instance of the word you want to replace (double click the word to select it quickly) then use the key combination CTRL-D which will select the closest next instance of the same word you have selected. Keep hitting CTRL-D until you have all the ones you want to replace selected. Then you can just type in your change and all selected words will get what you type in.

    • @easontee1351
      @easontee1351 5 ปีที่แล้ว +1

      Thanks Jim, it is helpful! Happy New Year!!

    • @nurglerider781
      @nurglerider781 5 ปีที่แล้ว +13

      Cannot up-vote this enough, my search-foo was failing on finding how this was done. P.S. It works exactly this way in VS Code as well.

    • @백영래-u3x
      @백영래-u3x 5 ปีที่แล้ว +1

      Thank you!

    • @rickole7404
      @rickole7404 5 ปีที่แล้ว +1

      thanks

    • @mikec64
      @mikec64 5 ปีที่แล้ว +4

      Thanks! Let's push this to the top of the comment stack.

  • @upendraroul343
    @upendraroul343 6 ปีที่แล้ว +23

    I'm learning data science and found your post in TH-cam for basic Python.. now I'm going through all of them... it's like watching a new English TV series.. don't have control to stop watching the next one.. All the best..

  • @lardosian
    @lardosian 6 ปีที่แล้ว +51

    Love your accent, sounds like a soft southern accent. Your content is fantastic.

  • @husseinsaad7969
    @husseinsaad7969 6 ปีที่แล้ว +25

    Clear voice, easy explanation, and great content ... keep going, man!

  • @jdratlif
    @jdratlif 2 ปีที่แล้ว +2

    Fantastic tutorial. Had been reading articles all day, but nothing clicked until I found this series.

  • @rishavtiwari2017
    @rishavtiwari2017 ปีที่แล้ว +5

    He explained everything in this course so well, so nicely & clearly. Really worth giving time to this playlist and learning so many stuffs in a simple procedure

  • @Frohuz
    @Frohuz 5 ปีที่แล้ว +10

    When started this tutorial my first thought was 'Wow, this guy is talking so fast, I won't be able to make it' but now I feel I understood everything you said and it all makes sense.
    Thank you

    • @amitsharma8337
      @amitsharma8337 4 ปีที่แล้ว

      Really? I'm watching his videos at 1.5x speed xD

    • @adityajoshi9207
      @adityajoshi9207 4 ปีที่แล้ว +3

      @@amitsharma8337 good for you

  • @enduringpromise
    @enduringpromise 5 ปีที่แล้ว +12

    I love how you are showing how to include bootstrap classes into the form. I also like how you showed how to customize the errors. Looking forward to completing this flask series.

  • @scarmusic90
    @scarmusic90 5 ปีที่แล้ว +5

    This is THE BEST online tutorials ever made. Thanks Corey!

  • @acousticintros8407
    @acousticintros8407 5 ปีที่แล้ว +7

    Im learning in my own pace, and take note I am only at my 3rd day and I was able to deploy to a web server. your tutorials are very good than the ones i purchased from Udemy.

  • @iansjackson
    @iansjackson 4 ปีที่แล้ว +1

    I have been up hill and down dale searching resources to get me started with Python/Flask/Web. I just want to say thank you, because what you are presenting here is the best I have found.

  • @manulorenzo8956
    @manulorenzo8956 5 ปีที่แล้ว +12

    Great Video.
    I would like to add a little snippet that allows you to close the Flash Message.
    {{ message }}
    ×

    This snippet fits in the layout page

    • @newmoodclown
      @newmoodclown 2 หลายเดือนก่อน

      for people using this, and if the button is not working with Bootstrap5, change data-dismiss="alert" to data-bs-dismiss="alert"

  • @treaper
    @treaper 5 ปีที่แล้ว +1

    Man, that little trick you did where you added extra cursors to every instance of "dir" that should've been "div" and edited them all at once...so elegant. Love the videos!

  • @anshupaul3423
    @anshupaul3423 6 ปีที่แล้ว +7

    Hello sir. I Just love your voice. First of all I was unable to find a proper source to learn python flask. But now I am literally in love with this python thing. I just want to learn more and more.
    What i like the most is the way you make us understand the things. Like I have attended many youtube and NPTEL tutorials, (Well currently I am doing BCA, so programming is the only zeal to live) but never found someone too deep and intense type of logic and explanation technique. I simply can't say that I love this. i want to breathe in it.

    • @coreyms
      @coreyms  6 ปีที่แล้ว +2

      Thanks! Glad you're enjoying programming more and more!

    • @anshupaul3423
      @anshupaul3423 6 ปีที่แล้ว

      Corey Schafer
      Thank u sir... 😊 Actually I have some doubts in this.. can u help me? If yes, please let me know how.... 🙂

  • @Blablaprimus
    @Blablaprimus 6 ปีที่แล้ว +8

    This content is amazing. Wouldn't expect as much from other official online courses - even paying ones.

  • @porlando12
    @porlando12 5 ปีที่แล้ว +5

    You've done it again. I'm super excited to start building my own professional website now! Thanks Corey!

  • @Quicksilver87878787
    @Quicksilver87878787 6 ปีที่แล้ว +2

    Thanks Corey. I've been through many tutor channels, and I must say yours is one of the best, if not the best. I especially like your speed - no "uuhhh" or "ummm" or speed humps. To the point and very good. You know your stuff!

  • @mm333-e1t
    @mm333-e1t 5 ปีที่แล้ว +4

    Man, u deserve a million likes for each of ur videos.. Super content and beautifully explained

  • @jacob.peters
    @jacob.peters 3 ปีที่แล้ว +1

    i've been going through these videos on an iPad Pro with pythonista and it's kinda wild honestly. love the videos

  • @SirCouchus
    @SirCouchus 5 ปีที่แล้ว +5

    Such a neat technology. I'm accustomed to using PHP for setting up websites and Flask feels so lightweight in comparison

  • @markwilde5683
    @markwilde5683 6 ปีที่แล้ว +22

    Dear Corey, you are a Rockstar. I love your teaching style, top man.

  • @keihansafi190
    @keihansafi190 3 ปีที่แล้ว +3

    Honestly I finished Flask Bootcamp By Jose @Udemy, and although his course give me an idea but yours are just another level. The fact that you explains it really well and step by step is the best teaching style for newbie.
    I might be wrong but I feel like some online videos are just offered by non-programmer by just using the exact documentation codes and explaining it without really making something.

  • @joeg816
    @joeg816 5 ปีที่แล้ว +2

    This is easily one of the best video courses I have ever seen. The content is well paced, clean and the chapters progress nicely.

  • @ivoivanov5320
    @ivoivanov5320 4 ปีที่แล้ว +3

    Thank you for the content Corey, great stuff! The least I can do is not skip the ads on the videos. Keep up the good work!

  • @mohammadghonchesefidi9238
    @mohammadghonchesefidi9238 6 ปีที่แล้ว +2

    DO we have even better teacher than Corey Schafer ? Of course not! I'm designing my support system using this course and until now it was great. After I finish this course I will share it in Github.

  • @Linux4Ever2011
    @Linux4Ever2011 6 ปีที่แล้ว +9

    Such useful information in a very simple way to understand, and above all free, this is just incredible. I really hope you continue doing such great videos. Thank you very much :) .

  • @chevulahaarvish4322
    @chevulahaarvish4322 ปีที่แล้ว

    i watched this video 2 years back and now watching same video for other project
    couldn't find much better video in past 2 years to skip this
    hatss of corey

  • @mattwilliams1844
    @mattwilliams1844 6 ปีที่แล้ว +5

    Was glad to see you make it onto the Talk Python podcast Corey. Your courses and material truly are very well done. Time to start launching some paid courses. When you do, I request Python with qt5. I will throw my money at a course with real life well done GUI applications. Especially if you are making it! Keep up the good work bud.

  • @PhilosopherKing73
    @PhilosopherKing73 3 ปีที่แล้ว +7

    Not sure if I missed this in the video, but I had to pip install email_validator to get it all to work…

    • @TheRealCSFY
      @TheRealCSFY 2 ปีที่แล้ว

      Great, thanks mate

  • @jacobmoore8734
    @jacobmoore8734 4 ปีที่แล้ว +10

    Every tutorial I think to myself, "this is the episode we start playing with javascript"...I know it's coming sooner or later!

  • @RuggieroGuida
    @RuggieroGuida 2 ปีที่แล้ว

    I wish youtube had an 'applause' button. These videos are amazing!

  • @cb1677
    @cb1677 6 ปีที่แล้ว +88

    "Hey there! How's it going everybody" is when you know it's time for LEARNING!

    • @cdishiyam9232
      @cdishiyam9232 4 ปีที่แล้ว

      30:41
      followed exactly everything word by word yet am not getting the success flash msg

  • @aeigreen
    @aeigreen 6 ปีที่แล้ว +2

    It could not be better then that ! what a great explanation of quality stuff. I have taken several on line classes. These instructions are the best.

  • @leodiamat6951
    @leodiamat6951 6 ปีที่แล้ว +3

    You're amazing man. Keep it up. Thanks for the FREE, very informative, full details and very good tutorials. God bless you beyond measure.

    • @lardosian
      @lardosian 6 ปีที่แล้ว

      Leo Diamat Exactly wat Leo said.

  • @andrenevares7543
    @andrenevares7543 4 ปีที่แล้ว +1

    I had to do a project in python for HARVARDX and this tutorial helps a LOT. I had put all info from Corey and links for the tutorial. Thanks for the job. Please, if you can, do a Deployment Tutorial for HTML, Bootstrap, and others for AWS, Hostgator.... This is one of the biggest problems for beginners. Congrats for such an incredible material

  • @aaronjameshorne
    @aaronjameshorne 5 ปีที่แล้ว +7

    I pay for this type of content. Learning a lot!

  • @ImmediatelyLeaveYT
    @ImmediatelyLeaveYT 3 ปีที่แล้ว +2

    thanks corey!!!

  • @adorkable81
    @adorkable81 5 ปีที่แล้ว +72

    17:03 Half of Internet screamming: "It's man, not "

  • @hallvardlundehervig5508
    @hallvardlundehervig5508 3 ปีที่แล้ว

    Hey man, thanks for this. Providing free high quality content is truly a noble thing to do. Keep it up!

  • @SkipperStyle
    @SkipperStyle 2 ปีที่แล้ว +3

    The validations aren't working as they do in the video (where the field border shows red and you get your flash messages) when I follow along and when I run the project code you share on GitHub in a virtual environment. I confirmed I have all the required dependencies. Does that code use features from when this video was made that have since been deprecated? Or is it more likely an issue with my machine if your own code also doesn't work for me?

  • @JoseLuisMorales
    @JoseLuisMorales 3 ปีที่แล้ว +1

    Best tutorial for Flask dummies ever , greetings for Venezuela

  • @nomeimporta6465
    @nomeimporta6465 3 ปีที่แล้ว +20

    Hi, if someone is having problems with the email validation, you only need to install and import "email_validator".

    • @koski7579
      @koski7579 2 ปีที่แล้ว +4

      Thank you :D

    • @englishproficiency6934
      @englishproficiency6934 2 ปีที่แล้ว +4

      Wow thanks! I lost a good 15 minutes before seeing your message :))

    • @mohammadaqdas7998
      @mohammadaqdas7998 ปีที่แล้ว

      Man! Thanks for the help

    • @mrklean0292
      @mrklean0292 3 หลายเดือนก่อน

      I had to actually do the following for it to work: pip install wtforms[email]. I tried pip install email_validator, but it didn't work that way. I kept getting errors.

  • @ChocolateWings7
    @ChocolateWings7 3 ปีที่แล้ว

    Thank you so much for another educational video on the Flask Web application, words can't express how grateful I am to have these courses available for free. Wish you all the best in everything you do Corey.

  • @hadikaes4633
    @hadikaes4633 5 ปีที่แล้ว +4

    this tutorial is so good, clear and to the point. keep it up!

  • @waronamogobye436
    @waronamogobye436 3 ปีที่แล้ว +2

    words cannot describe how amazing this guy is🤗

  • @aman4434
    @aman4434 4 ปีที่แล้ว +63

    Corey typing div as dir just to let us know that he is actually human

    • @arnavchoudhury4453
      @arnavchoudhury4453 4 ปีที่แล้ว +5

      He purposely makes errors to make us think he's human but in fact he is not

    • @jasasul8164
      @jasasul8164 4 ปีที่แล้ว +9

      meanwhile me copying dir everywhere because according to the documentation it was a legal tag

    • @Mayur7Garg
      @Mayur7Garg 3 ปีที่แล้ว +1

      dir is an actual tag which made it all the more confusing. I was going around googling what tag I could replace it with since 'dir' is deprecated!! ;-)

    • @xxmonopowerxx2360
      @xxmonopowerxx2360 3 ปีที่แล้ว +1

      Hahahahaha xD

  • @chandrakant6283
    @chandrakant6283 3 ปีที่แล้ว +1

    Everything going smooth so far.

  • @kerwinso
    @kerwinso 5 ปีที่แล้ว +5

    Note: Flask-WTF is not the same as WTForms. Flask-WTF includes the WTForms package and integrates it with Flask, as well as additional features like CSRF, file upload, and reCAPTCHA.

    • @736939
      @736939 5 ปีที่แล้ว

      wtf?

  • @balakiswe
    @balakiswe 5 ปีที่แล้ว +2

    Corey is effortless... excellent tutor... I can even pay for your tutorial may be on Udemy..

  • @mahdihosseinali7492
    @mahdihosseinali7492 4 ปีที่แล้ว +5

    I love your tutorials, just wish you had made this without bootstrap, something simple so one could understand the flask, then add bootstrap on top of it in a separate tutorial.

  • @ahmadmuradi6552
    @ahmadmuradi6552 ปีที่แล้ว

    Hello Mr. Schafer, your videos are great! not only that but the way you explain it is great too. Thank you, very much for your hard work.

  • @user-sg7yd5il3z
    @user-sg7yd5il3z 3 ปีที่แล้ว +7

    Anyone else missing the 'This field is required' text at 37:31? Even after copying the register.html from his github I'm still not getting that.

    • @qwerty-6573
      @qwerty-6573 3 ปีที่แล้ว

      Same here!

    • @alexkumpula
      @alexkumpula 3 ปีที่แล้ว +8

      I had this issue too, but I was able to fix it.
      I did the following:
      Change to
      This seemed to do the trick! I got this from blog.miguelgrinberg.com/post/the-flask-mega-tutorial-part-iii-web-forms
      Here is the reasoning from the website (by Miguel Grinberg): "The novalidate attribute is used to tell the web browser to not apply validation to the fields in this form, which effectively leaves this task to the Flask application running in the server."
      I hope this helps whoever reads this!

    • @vladinstein
      @vladinstein 2 ปีที่แล้ว +1

      @@alexkumpula Thank you so much! I was so frustrated with this.
      That's because WTForms places this 'required maxlength="20" minlength="2" ' into HTML and therefore it doesn't let you submit the form unless it fits the criteria. That's why there were no error messages.
      Your solution is perfect!

    • @alexkumpula
      @alexkumpula 2 ปีที่แล้ว +1

      @@vladinstein Glad it could help so long after I posted it haha!

  • @Ash_Industries
    @Ash_Industries 3 ปีที่แล้ว +1

    Your videos blow me away every time.

  • @modoulaminceesay9211
    @modoulaminceesay9211 2 ปีที่แล้ว +3

    people doing this now it will be important to pip install email validator

  • @daisygirl488
    @daisygirl488 4 ปีที่แล้ว

    Just started this series a few days ago and I wanted to say thank you so much for all your effort in making these videos! Thyere very helpful to a beginner to flask like me :)

  • @jahin5745
    @jahin5745 4 ปีที่แล้ว +7

    Hi, I love your tutorial videos!
    1:16 "pip install flask-wtf" XD

  • @bhoomeendra
    @bhoomeendra 6 ปีที่แล้ว +1

    These videos are very thorough and in-depth and the way of teach is just awesome keep doing this stuff for us thanks for this awesome free content

  • @Thedevineforce
    @Thedevineforce 4 ปีที่แล้ว +7

    @Corey Thank you again for wonderful tutorial. Quick question @25:43
    "if form.validate_on_submit():", how can we validate the form before rendering the template? Appreciate your response. Thanks

  • @roboedar
    @roboedar 5 ปีที่แล้ว +1

    Thank you so much for your videos. Of all tutorials online yours are definitely the easiest to understand.

  • @investandcyclecheap4890
    @investandcyclecheap4890 2 ปีที่แล้ว +9

    For anyone having validation errors, use this code. This code will find any form errors and summarize them at the top of the form.
    {% if form.is_submitted() and form.errors|count > 0 %}
    {{ form.errors|count }} error(s):

    {% for field_name, field_errors in form.errors|dictsort if field_errors %}
    {% for error in field_errors %}
    {{ form[field_name].label }}: {{ error }}
    {% endfor %}
    {% endfor %}

    {% endif %}

    • @pranjalshukla8096
      @pranjalshukla8096 ปีที่แล้ว

      time stamp?

    • @kizernis
      @kizernis ปีที่แล้ว

      This helped me to find out that I spelled EqualTo('Password') instead of EqualTo('password') for the confirm password field!

  • @babukothandaraman984
    @babukothandaraman984 3 ปีที่แล้ว

    Hi Corey,
    Thanks for your wonderful tutorials. I'm not a techie. But still could follow your videos without any second thoughts.

  • @yingzehou1551
    @yingzehou1551 4 ปีที่แล้ว +6

    Just curious, how advanced should I learn HTML in order to write out these codes by myself. This series is awesome but I no almost nothing about HTML programming, so it's hard for me to customize my own web app

    • @agd4858
      @agd4858 2 ปีที่แล้ว

      HTML basics will be enough.

    • @smoshabi
      @smoshabi 2 ปีที่แล้ว

      You need to know more than just basics. You have to know Bootstrap too to follow this tutorial.

  • @sushisavant
    @sushisavant 5 ปีที่แล้ว +1

    This was very easy to follow along to, thank you for taking the effort to make these tutorials.

  • @almunteanu5
    @almunteanu5 6 ปีที่แล้ว +3

    Hi, Corey! Thanks a lot for all your content, it has helped me a lot in my journey with Python. Definitely considering becoming a patron.
    Just a quick question: as a professional web developer, do you have to know all these tiny details of Bootstrap, such as different class names, specific tags etc?

    • @coreyms
      @coreyms  6 ปีที่แล้ว +9

      Thanks! And no, I wouldn't say that you have to know all of this with Bootstrap. I even had to look a lot of that stuff up when planning the video. If you're going to be a web developer then it would likely be better to know the fundamentals of CSS and JavaScript so that you can write your own styles and behaviors for your site.

  • @kevinbinala7539
    @kevinbinala7539 4 ปีที่แล้ว

    Thanks Corey! I' m loving this series! By far one of the most python flask tutorial! cheers mate!

  • @treelight1707
    @treelight1707 6 ปีที่แล้ว +144

    wtf for wt-forms. I'm sure the creators didn't have any other thoughts about the name ;)

    • @drozdekPty
      @drozdekPty 5 ปีที่แล้ว +4

      Have though exactly about the same lol

    • @CodingMazaa
      @CodingMazaa 5 ปีที่แล้ว +4

      Yeah, even i was a bit shocked at their choice of name. Goes to prove that geeks are lousy at naming things.

    • @varunpatwardhan1780
      @varunpatwardhan1780 5 ปีที่แล้ว +6

      I think that naming was done very intentionally - developers of the framework must love the attention :)

    • @JethroYSCao
      @JethroYSCao 5 ปีที่แล้ว +5

      It's kind of a tradition in tech to make covertly humorous names like these. Best example that comes to mind would be "eunuchs", a pun for the OG of OS's that we all know and love, Unix.

    • @dev-playing-gt
      @dev-playing-gt 5 ปีที่แล้ว

      What is wt-form? I'm kind of confused because the module suddenly came out.

  • @inspired2776
    @inspired2776 4 ปีที่แล้ว

    your channel need real appreciation coz u provide free course which help like us student alot

  • @user-oz5hi1px7e
    @user-oz5hi1px7e 5 ปีที่แล้ว +7

    "pretty good so far?"
    me: "Prettiest so far"

  • @arghoshj
    @arghoshj 6 ปีที่แล้ว +2

    In one word It's awesome !!.. Thanks Corey for this nice tutorial.

  • @satyap3654
    @satyap3654 4 ปีที่แล้ว +18

    I'm getting an error named
    No module named Forms found

    • @shibajyotidas2043
      @shibajyotidas2043 4 ปีที่แล้ว

      same here,i couldnt find a way to resolve it

    • @_SarveshJoshi
      @_SarveshJoshi 4 ปีที่แล้ว

      I was getting same error, Try Sending Full Path of Your Forms File.
      My Tree Was
      FlaskCode - PythonCodes - Forms.py
      so I Entered from FlaskCode.PythonCodes.Forms
      and It Worked.

    • @_SarveshJoshi
      @_SarveshJoshi 4 ปีที่แล้ว

      @@shibajyotidas2043 Check My Previous Comment.

    • @rahulrokade2048
      @rahulrokade2048 4 ปีที่แล้ว +1

      keep your flaskblog.py and forms.py file in the same folder

    • @andrewhunnter
      @andrewhunnter 4 ปีที่แล้ว

      still doesn’t work and I’m using pipenv to keep all of my modules installed in virtual envs

  • @bobross3880
    @bobross3880 3 ปีที่แล้ว

    I love this. I don't know if I've gotten better at learning or what, but im able to fully keep up with what you're doing in real time and understand how it works. Maybe because you're using actual real world examples I can relate to rather than some "here is functionality, now u try"

    • @bobross3880
      @bobross3880 3 ปีที่แล้ว

      Spoke too soon. All the html tags and classes are lost on me ooof

    • @bobross3880
      @bobross3880 3 ปีที่แล้ว

      Oh fuck me. I have errors with the imports even after pip install

  • @victorialazareva
    @victorialazareva 6 ปีที่แล้ว +4

    My form did not validate, through debugging I found out the problem was with the confirm password field. I had EqualTo(password) instead of EqualTo('password'). Writing this just in case someone has the same problem

    • @mecskap
      @mecskap 6 ปีที่แล้ว

      try this code :
      class RegistrationForm(FlaskForm):
      username = StringField('Username', validators=[DataRequired(), Length(min=2, max=20)])
      email = StringField('Email', validators=[DataRequired(), Email()])
      password = PasswordField('Password', validators = [DataRequired(),EqualTo('confirm_password')])
      conform_password = PasswordField('Conform Password', validators=[DataRequired()])
      submit = SubmitField('Sign Up')

    • @andrewmitchell7998
      @andrewmitchell7998 5 ปีที่แล้ว

      Thanks, I was stuck until I found your comment. In my case, I had ('Password') instead of ('password'). It is the name of the variable in Python that needs to be passed in to the EqualTo function, not the string that is used on the form

    • @frankm.8943
      @frankm.8943 5 ปีที่แล้ว

      This comment really helped me out, thanks!

    • @oktariantb5206
      @oktariantb5206 5 ปีที่แล้ว

      You've saved me! Already spent 20mn looking for the solution until I saw your comment!

  • @danielmcewan498
    @danielmcewan498 4 ปีที่แล้ว +2

    I love the tutorial. I have learnt so much about python. Thank you so much Corey! I love your videos! Liked and subscribed!

  • @TheFashionsketcher
    @TheFashionsketcher 5 ปีที่แล้ว +9

    Hey! For some reason after clicking submit button on the register page I am not redirected to the home page. I don't know why that happens. Everything seems to be fine...

    • @vik_theafrican
      @vik_theafrican 5 ปีที่แล้ว

      same problem...did you find a solution?

    • @createlobo
      @createlobo 5 ปีที่แล้ว +1

      @@vik_theafrican ​ Make sure your register.html is set up correctly. I just faced the same problem.

    • @vik_theafrican
      @vik_theafrican 5 ปีที่แล้ว +2

      @@createlobo turns out i had left out {{ form.hidden_tag() }}

    • @createlobo
      @createlobo 5 ปีที่แล้ว

      @@vik_theafrican glad you got it working again. :)

    • @christopherkirkley2969
      @christopherkirkley2969 4 ปีที่แล้ว

      @@vik_theafrican same problem - thanks!

  • @pythusiast4701
    @pythusiast4701 3 ปีที่แล้ว

    Corey Schafer is my HERO!!

  • @bhakti4718
    @bhakti4718 6 ปีที่แล้ว +4

    I didn't get the error messages in the form, just glowing the field with red color around it. any ideas?

    • @thegreatcornholio6436
      @thegreatcornholio6436 5 ปีที่แล้ว +2

      It's up to an html5 browser feature, which prevalidates the user input.
      To deactivate the feature, you have to add the novalidate attribute to your form tag in your register.html!

    • @AMPClippedup
      @AMPClippedup 5 ปีที่แล้ว

      In addition to @The Great Cornholio, when you do the for loop, make sure the iterator is named error, not errors. So it should look like this
      {% for error in form.password.errors %}
      {{ error }}
      {% endfor %}
      and not
      {% for errors in form.password.errors %}
      {{ error }}
      {% endfor %}

    • @javierperez9844
      @javierperez9844 4 ปีที่แล้ว

      To anyone else struggling with this just changed the form tag to:

    • @jaspersj23
      @jaspersj23 4 ปีที่แล้ว

      @@javierperez9844 thankyou!!!!!!

  • @massimehrkhah607
    @massimehrkhah607 5 ปีที่แล้ว +2

    These series of videos are great, thanks!

  • @mahdirezayi9090
    @mahdirezayi9090 5 ปีที่แล้ว +5

    @CoreySchafer flask.cli.NoAppException: While importing "flaskblog", an ImportError was raised:
    from forms import RegistrationForm, LoginForm
    ModuleNotFoundError: No module named 'forms'
    please help me i have this problem

    • @haseebabbas6305
      @haseebabbas6305 4 ปีที่แล้ว

      do you remember how did you fix it??

    • @haseebabbas6305
      @haseebabbas6305 4 ปีที่แล้ว

      @@someguy9367 hey there..!! is your problem got solved? because I'm facing the same issue.. Kindly help me if you have solved the issue.

    • @haseebabbas6305
      @haseebabbas6305 4 ปีที่แล้ว

      @@someguy9367 thank you for the reply sir, bit it is not syntax error i've already searched.. do let me know please when you have time to go through this error, it would be every nice of you if you solve my issue.

    • @someguy9367
      @someguy9367 4 ปีที่แล้ว +2

      ​@@haseebabbas6305 i fixed it by importing in the flaskblog file this : from flask import render_template, url_for, flash, redirect
      from forms import RegistrationForm, LoginForm
      from flask import *
      -
      And in the forms file : from flask_wtf import FlaskForm
      from wtforms import StringField, PasswordField, SubmitField, BooleanField
      from wtforms.validators import DataRequired, Length, Email, EqualTo

    • @haseebabbas6305
      @haseebabbas6305 4 ปีที่แล้ว

      @@someguy9367 thank you for this bro.. thank you very very muchhh.......

  • @maximolema
    @maximolema 5 ปีที่แล้ว +1

    very complete and clear explanation of flask forms

  • @user-ln8hq4wt8c
    @user-ln8hq4wt8c 6 ปีที่แล้ว +57

    The html part is so confusing to me

    • @rippernmode8015
      @rippernmode8015 4 ปีที่แล้ว +3

      Khan academy has some extremely easy to learn courses for html and css for complete begginers if youre interrested.

    • @silverzero9524
      @silverzero9524 4 ปีที่แล้ว

      same

    • @demigod6190
      @demigod6190 4 ปีที่แล้ว

      same here dude

    • @silverzero9524
      @silverzero9524 4 ปีที่แล้ว +1

      @@demigod6190 just ignore the html in this video. in other videos the html is little easier to follow so you may get most of it. Just keep following this series its good

    • @mezianibelkacem650
      @mezianibelkacem650 4 ปีที่แล้ว

      @@rippernmode8015 yes i m interrested!

  • @nitkarshchourasia2406
    @nitkarshchourasia2406 8 หลายเดือนก่อน +1

    🎯 Key Takeaways for quick navigation:
    00:00 🌐 *This video focuses on creating forms and validating user input using the Flask framework.*
    01:09 📦 *The tutorial introduces WTForms, a popular Flask extension for handling forms, simplifying common tasks like validation.*
    02:59 🔑 *WTForms allows the creation of form classes in Python, which are then automatically converted into HTML forms in templates.*
    05:01 🧠 *Validators like `DataRequired` and `Length` are used to ensure input integrity, providing an easy way to enforce constraints.*
    10:33 🔐 *Setting a secret key in Flask protects against certain attacks; a good practice is generating a secure key using the `secrets` module.*
    12:35 📝 *The tutorial demonstrates how to create registration and login routes, utilizing form instances and rendering templates accordingly.*
    16:03 🛡️ *Including a hidden CSRF token in the form protects against cross-site request forgery attacks, enhancing security.*
    20:23 🔄 *The tutorial covers creating links between registration and login pages, providing a seamless user experience.*
    22:26 🌐 *The registration form in the Flask web app is successfully created, including fields for username, email, password, and confirm password.*
    23:40 📝 *To accept both GET and POST requests for the registration route, use `methods=['GET', 'POST']` in the route decorator.*
    25:00 🚦 *Utilize Flask's flash messages to provide one-time alerts; these can be used for user feedback on successful actions, such as creating an account.*
    27:40 🚀 *After successful form submission, redirect the user to another page (e.g., home) using `return redirect(url_for('home'))`.*
    32:30 🚨 *Implement validation feedback for the user by displaying specific error messages next to the corresponding form fields.*
    38:25 🔄 *The login page can be quickly created by duplicating the registration template and adjusting fields accordingly, removing unnecessary ones.*
    43:30 ⚠️ *Simulate a login process for testing purposes by checking submitted data; use flash messages to communicate success or failure with the user.*
    44:36 🚧 *When simulating a login for testing, ensure the server is running, and watch for any file mistakes that might disrupt the process.*
    45:04 🚫 *Attempting a login with incorrect credentials triggers a red danger alert, providing user feedback on unsuccessful login attempts.*
    45:17 ✅ *Successful login redirects the user to the home route with a confirmation message.*
    46:00 🌐 *Utilize the `url_for` function to dynamically generate URLs, ensuring links in templates automatically adjust to route changes.*
    46:43 🧩 *Convert direct links in templates to use `url_for` for flexibility in adapting to changes in route structure.*
    47:23 📁 *The next video will cover integrating a database to store user information and implement a functional registration and login system.*

  • @anup2565
    @anup2565 5 ปีที่แล้ว +3

    Im running the output on chrome and IE, i dont get the above ribbon as corey does in his video - The one with Flask blog and the home, about , login, register links. What am i missing?

    • @haseebabbas6305
      @haseebabbas6305 4 ปีที่แล้ว

      Same issue I'm facing right now.. Do you remember how did you solved it??? if yes, then plz help me.

    • @usharoyal24
      @usharoyal24 3 ปีที่แล้ว

      Same here also if u solved that problem plz tell me solution to that

  • @havehalkow
    @havehalkow ปีที่แล้ว +2

    If someone gets an error like "install email_validator for email validation support..."
    What worked for me is installing the email validator using the command:
    pip install wtforms[email].

    • @rubenvanderwolf3236
      @rubenvanderwolf3236 ปีที่แล้ว

      Thanks, I got that error, but this was the trick to make it work!

  • @AlexanderJrFiel
    @AlexanderJrFiel 6 ปีที่แล้ว +4

    hi sir, i've got an error on hidden_tag it says jinja2.exceptions.UndefinedError: 'function object' has no attribute 'hidden_tag'. I copy and paste your code but still no avail.
    i already figure it. I have a typo's in my flaskblog.py. it is running now. Thank you

    • @ruandias6257
      @ruandias6257 5 ปีที่แล้ว

      Hey man , the same error here! Can you help me ?!

    • @SahilMandre
      @SahilMandre 5 ปีที่แล้ว

      Please help me I am facing same problem

  • @ronaldjohnson4470
    @ronaldjohnson4470 6 ปีที่แล้ว +2

    You are truly a great instructor.

  • @saisritejakuppa9856
    @saisritejakuppa9856 5 ปีที่แล้ว +3

    flash(f'Account created for {form.username.data}!', 'success')
    I am getting invalid syntax in this line can anyone help..... I am working on windows

    • @kyleburris4558
      @kyleburris4558 5 ปีที่แล้ว +6

      Try this syntax: flash('Account created for {}!'.format(form.username.data), 'success')

    • @normanlove222
      @normanlove222 5 ปีที่แล้ว

      yeah its because you dont have python 3.6 or higher

  • @klajdikaca1991
    @klajdikaca1991 4 ปีที่แล้ว +2

    i found my solution after trying everything.For those using pycharm,go to file/settings/chose the project/project interpreter.
    Then you will se al your packages,click + button and search for email-validator, not email_validator. Its should be version 1.1.1 from author Joshua.

    • @bevy3794
      @bevy3794 3 ปีที่แล้ว

      you saved my life! thank you 😘😂

  • @sanskritiagrawal6108
    @sanskritiagrawal6108 4 ปีที่แล้ว +4

    My validate_on_submit didn't really work even though I added the same code. It dies not give any error but does not work too? Any idea what's wrong?

    • @pr02640
      @pr02640 4 ปีที่แล้ว

      for me also, it just came back to home page with the green bar but no flash message. just blank. :(

    • @sagarpandey9998
      @sagarpandey9998 3 ปีที่แล้ว

      Did you find a solution to this

    • @sanskritiagrawal6108
      @sanskritiagrawal6108 3 ปีที่แล้ว

      @@sagarpandey9998 no I could not🤷‍♀️

  • @yadavrajsky-trips
    @yadavrajsky-trips 4 ปีที่แล้ว +1

    Thank you Sir 😊 you are awesome. I am from India and I would surely like to meet you at least once in my lifetime. Thanks alot for your descriptive and practice approach videos.

  • @J_Bogey
    @J_Bogey 6 ปีที่แล้ว +3

    Hey Corey I'm having an issue with the very last portion. In the login function it's like the conditional statement isn't being evaluated at all. The messages from the validators are working fine but the flash and redirection functionality when you type in the correct info doesn't work. Which is strange because the portion in the register function works just fine.

    • @J_Bogey
      @J_Bogey 6 ปีที่แล้ว

      Nvm I had left the username stringfield in the LoginForm class

  • @heisenburgfreed7591
    @heisenburgfreed7591 4 ปีที่แล้ว

    Great tutorial, Thank you Corey Schafer!
    You are the reason I can make the final decision of learning Python.

  • @Jeptxxle
    @Jeptxxle 5 ปีที่แล้ว +8

    If someone is having problems trying to importing flask_wtf try this:
    pip3.6 install --user Flask-WTF

    • @drewcourtney376
      @drewcourtney376 5 ปีที่แล้ว +2

      THANK YOU!!!

    • @poojakhatri4426
      @poojakhatri4426 4 ปีที่แล้ว

      I get same error but trying your command says pip3.6 is not recognized as int or external command

    • @kalinkamarinka
      @kalinkamarinka 3 ปีที่แล้ว

      pip3 is ok as well

  • @ethanroman6883
    @ethanroman6883 4 ปีที่แล้ว +1

    The best Flask Tutorials