Python Flask Tutorial: Full-Featured Web App Part 7 - User Account and Profile Picture

Поделиться
HTML-код
  • Опубликовано: 5 ноя 2024

Комментарии • 465

  • @codewithgedo3067
    @codewithgedo3067 3 месяца назад +4

    In 2024, this is still the best Flask tutorial on the Internet due to its comprehensive coverage of topics, clear explanations, and up-to-date practices.

  • @MistaT44
    @MistaT44 6 лет назад +189

    I'm in my final semester of my degree right now! and the first thing I am going to do as soon as I land a job is to support this channel! This series is just AMAZING!

  • @arseneawounou180
    @arseneawounou180 2 года назад +4

    Watching this series 4 years later and I strongly recommend. Learning a lot.

  • @soumyajitdey5720
    @soumyajitdey5720 4 года назад +29

    Corey! I have an interview tomorrow wish me luck! If I get this job the first thing I'll do is support you through Patreon with my first salary. You have taught things so efficiently that no professor has ever taught in these semesters for graduation. You're such a kind person for teaching such valuable content with this brilliant quantity without charging a penny!

    • @soumyajitdey5720
      @soumyajitdey5720 4 года назад +13

      @Raptr3x yes mate I got the job. Currently working as a Data Engineer. 😊

    • @davidcairuz
      @davidcairuz 4 года назад

      @@soumyajitdey5720 Nice, congrats! :D

    • @darius349
      @darius349 4 года назад

      @@soumyajitdey5720 Congratulations!!

    • @temiloluwaadebowale2553
      @temiloluwaadebowale2553 3 года назад +1

      @@soumyajitdey5720 What path would you recommend (or did you take) on your way to becoming a data engineer?
      Also I'd like to connect with you on LinkedIn or an other social platform.
      Thanks!

    • @MrSreeCharan
      @MrSreeCharan Год назад +1

      How r u doing broo

  • @kirkkenney6510
    @kirkkenney6510 5 лет назад +59

    For anyone wanting to delete the previous profile picture while adding a new one, I added this just before the return statement in the save_picture function:
    prev_picture = os.path.join(app.root_path, 'static/profile_pics', current_user.image_file)
    if os.path.exists(prev_picture):
    os.remove(prev_picture)

    • @meow11119
      @meow11119 4 года назад +1

      thank you :)

    • @darynaishchuk5350
      @darynaishchuk5350 4 года назад +10

      You also need to check that previous picture wasn't the default one, because it will also be deleted.

    • @marconarca2706
      @marconarca2706 4 года назад

      @@darynaishchuk5350 yeah i thought also

    • @heisenburgfreed7591
      @heisenburgfreed7591 4 года назад +16

      The code for anyone who wants to delete the previous profile picture (but never delete the default.jpg) while adding a new one, please add the below code block before the return statement inside the save_picture function:
      # Code Block Starts
      prev_picture = os.path.join(app.root_path, 'static/profile_pics', current_user.image_file)
      if os.path.exists(prev_picture) and os.path.basename(prev_picture) != 'default.jpg':
      os.remove(prev_picture)
      # Code Block Ends

    • @user-sg7yd5il3z
      @user-sg7yd5il3z 3 года назад +4

      @@heisenburgfreed7591 could just do
      and current_user.image_file != 'default.jpg':
      either one works. Yours kinda keeps it more consistent with the os.path thing
      Thanks OP. Was struggling with this before this comment.

  • @rusinsr
    @rusinsr 6 лет назад +50

    The pacing of these tutorials and your explanations are just incredible! Shared the series with my Python friends :)

  • @kizernis
    @kizernis Год назад +1

    Mr. Schafer is like a teaching machine! Always keeps all things in mind and never stutters or says anything unnecessary!

  • @arinzealex
    @arinzealex 4 года назад +4

    I really love the fact that whenever I run into any error following these amazing tutorials, the error has been asked and answered in the comments :)

  • @tylmomendog
    @tylmomendog 6 лет назад +111

    Fantastic series, Corey. Pacing, content, thoroughness, and execution is just great. Thank you for the quality content!

    • @xtrzne
      @xtrzne 2 года назад

      Can anyone clarify if the profile picture is being fetched from the server or from the local filesystem (when GET request is called on the account page)? To me it seems like while the file name is sent to the SQL database, the actual image isn't being sent to the database at all?

    • @kizernis
      @kizernis Год назад

      ​@@xtrzne A little late, but I'll answer for those who wonder. After a picture is selected from a local file system on the webpage, it's being put (its resized copy) onto the local filesystem *by the server* (which is now being run locally) into *static/profile_pics* directory. Only the filename goes into the database. It's often a bad thing to store bitmaps in the database as blobs.

  • @ian_senior
    @ian_senior 5 лет назад +42

    loving this tutorial!
    i added the code to delete the old profile pic when updating with a new one. this is the if statement in the account function in routes.py
    ```
    if form.picture.data:
    old_pic = current_user.image_file
    picture_file = save_picture(form.picture.data)
    current_user.image_file = picture_file
    if old_pic != 'default.jpg':
    os.remove(os.path.join(app.root_path, 'static/profile_pics', old_pic))
    ```

  • @ryszardkalisz733
    @ryszardkalisz733 6 лет назад +6

    Thank you for the best content when it comes to python and Flask tutorials.
    I tried to learn Flask a little too early in my programming journey and when i was stuck i started to search for another tutorial instead of improving my skills.
    I came back crawling to you Corey QUICK.
    Thank you!

  • @serta5727
    @serta5727 4 года назад +2

    Seriously been searching for days for a complete flask webapp build tutorial. This and from sentdex were the BEST!

  • @AbhishekNigam
    @AbhishekNigam 6 лет назад +4

    This is has become on of the best code tutorials I've ever watched on RUclips!

  • @Thattyguy_
    @Thattyguy_ 6 лет назад +3

    I like how you started referencing where we set the variable in the past, helps keep track of structure better

  • @MuskanMall-y6d
    @MuskanMall-y6d 11 месяцев назад

    I have no experience using any backend framework, except some basic django...
    I did not expect such an amazing quality from a RUclips tutorial, which is free!
    thankyou!
    this is an amazing series!
    you're god sent for broke students!

  • @PedroHenrique-ne3zm
    @PedroHenrique-ne3zm 2 года назад

    Hello, my name is Pedro and I live in São Paulo, I am writing this text to thank you immensely because you are not only helping me in my professional life but also in my academic life. Keep being this amazing person that you are and may there be others like you over the years, thank you very much.

  • @chakibbrikcisid5474
    @chakibbrikcisid5474 5 лет назад +18

    Duuuuuuuuuuuude, you're a beeeaaaaaaaaaast !
    Your tutorials are awesome ! keep the good work !
    If you could put a series about Laravel that would be dope !
    You got some high quality skills in teaching !
    Thanks a lot !

  • @vinodhr8805
    @vinodhr8805 5 лет назад +4

    Corey, Your python videos are really amazing. I started python programming after a decade and I'm into it now. But my job is mostly in automation testing. Wanted to change to development and picked your series. Can't stop in btw, yesterday I started and now I'm in part 7. With this video reference, I can able to build the website. Amazing Work!!

  • @RandomShowerThoughts
    @RandomShowerThoughts 6 лет назад +8

    One of the best tutorials on anything i've ever watched

  • @lightninginmyhands4878
    @lightninginmyhands4878 5 лет назад +6

    Another LEGENDARY vid!
    When I saw you install Pillow, I thought to myself "Python is like the car, and these extensions are like aftermarket parts... " :)

  • @souravpal6406
    @souravpal6406 4 года назад +1

    This tutorial is way better than some of the payed courses online. Thank you. This is excellent...

  • @investmentapps7826
    @investmentapps7826 3 года назад +1

    I am glad I make typos i.e. pictures instead of picture. Helps me understand when I troubleshoot issues. Thank you,

  • @dawnS33ker
    @dawnS33ker Год назад +1

    Corey, I can't thank you enough for this series. Amazing work..

  • @jimmydesilva
    @jimmydesilva 6 лет назад +3

    In order to make the picture upload work on the current version of Python and Flask, in "forms.py" I had to change:
    [code]
    picture = FileField('Update profile picture', validators=[FileAllowed('jpg', 'png')])
    [/code]
    to:
    [code]
    picture = FileField('image', validators=[FileRequired(), FileAllowed(['jpg', 'png'], 'Images only!')])
    [/code]
    Last but not least, thank you for the great series!

    • @h82fail
      @h82fail 6 лет назад +4

      I think you only had a problem because you forgot to put the file types into a list. [FileAllowed('jpg', 'png')]) should have been [FileAllowed(['jpg', 'png'])]). He had the brackets correct in the video and it worked for me on the newest version. When I was following along I wasnt expecting to have to use the list, so I'm guessing you thought the same and didn't notice him do it.

    • @jimmydesilva
      @jimmydesilva 6 лет назад

      @@h82fail I see what I did wrong now. Thanks for pointing it out!

  • @alexkalopsia
    @alexkalopsia 4 года назад +5

    If you want to prevent avatars from stretching, add object-fit:cover; to the .account-img class in main.css

  • @rahulsailwal4025
    @rahulsailwal4025 4 года назад +1

    every bit i m developing while seeing your videos making me so happy and the reason is you.
    Thank you so much for amazing video...God bless you.

  • @VitorAraujo010
    @VitorAraujo010 4 года назад +2

    These are sensational tutorials Corey, thanks and please expand on the features!

  • @sknganga3633
    @sknganga3633 3 года назад +1

    corey schafer is forever a legend!

  • @IncognitoAtreides
    @IncognitoAtreides 3 года назад

    This is even better than the CS50 Webapp tutorials at Uni!

  • @rahultiwari4309
    @rahultiwari4309 4 года назад

    A video of master Corey just make my day like nothing

  • @DocPosture
    @DocPosture 6 лет назад +2

    even on these longer vids, the pacing is spot on. subscribed

  • @ErickG
    @ErickG 5 лет назад +8

    I've never felt dumber and smarter while watching a video. I guess that's still progress. Thank you

  • @sivarampatamsetti2262
    @sivarampatamsetti2262 4 года назад

    I WONDER !!!!!
    how much practice it takes to teach like this
    💯 helpful
    GREAT,THANK YOU.

  • @ahmadabdallah2896
    @ahmadabdallah2896 5 лет назад +19

    Dude your dog is so cute omg

  • @vgbond2423
    @vgbond2423 3 года назад +1

    tbh, this is the best flask tutttoriallll for beginnerr.....

  • @kartikxramesh
    @kartikxramesh 4 года назад +3

    What a cute photo of your dog! Looks like a good boy.

  • @SAGARSHARMA-cd8pj
    @SAGARSHARMA-cd8pj 6 лет назад +1

    For the profile picture @21:57 , I had to change
    picture = FileField( 'Update Profile Picture', validators= [ FileAllowed ( [ 'jpg', 'png' ] ) ] )
    to
    picture = FileField( 'Update Profile Picture', validators=[ FileRequired(), FileAllowed ( [ 'jpg', 'png' ] ) ] )
    and also
    import FileRequired
    at the starting of the file.
    maybe because I'm using Python3.5 and not 3.6
    Thanks for the awesome tutorials @CoreySchafer

    • @geom8235
      @geom8235 5 лет назад

      thanks, brother!

  • @plusk343
    @plusk343 4 года назад +6

    I am a teen. As soon as I land a settled job, I am gonna support this channel
    Remember This Comment

    • @plusk343
      @plusk343 4 года назад +1

      @@photon6156 cool, see you here after 6 years

    • @plusk343
      @plusk343 10 месяцев назад

      yo i am here, 3 years before time

    • @plusk343
      @plusk343 10 месяцев назад

      i have the money now

    • @plusk343
      @plusk343 10 месяцев назад

      i just turned 18 like 10 days ago, im gonna get my paypal and support this guy

  • @MistaT44
    @MistaT44 6 лет назад +3

    I guarantee you'd be a millionaire if these were paid courses. thankyou for providing this godlike content for absolutely free!

  • @TheGlenn1976
    @TheGlenn1976 5 лет назад +1

    as a zero knowledge person about coding, i wonder how did I able to go this far in the series(Part 8) and be able to successfully roll out the apps. Thank you for these videos. I am very excited finishing this apps.

  • @isevitt
    @isevitt 4 года назад +2

    I fell in love with Flask because of you :)

  • @gonzalopolo2612
    @gonzalopolo2612 5 лет назад +2

    This videos are amazing and complete, support this channel is a must!
    Just a question for the audience, to see if someone is having the same problem:
    - On the account route, when updating the current_user.name and current_user.email with the form data, then doing the db.session.commit() is not updating the DB but the commit returns None as if everything was Ok, has somebody run into the same problem??
    Thank you very much again!

  • @zainbaloch5541
    @zainbaloch5541 5 лет назад +3

    Quality content continues. Respect from Pakistan!

  • @taruneagles1
    @taruneagles1 6 лет назад +2

    Just fyi, this video used
    picture_path = os.path.join(app.root_path + "static/profile_pics" + picture_fn)
    Corey is using mac, and it works for him, but for people using windows please use:
    picture_path = os.path.join(app.root_path + r"\static\profile_pics\\" + picture_fn)

    • @coreyms
      @coreyms  6 лет назад +2

      Thanks for catching that! I think the best solution is to simply pass in static and profile_pics as different arguments like so...
      picture_path = os.path.join(app.root_path, "static", "profile_pics", picture_fn)
      I will issue a correction in the next video I add to this series. Thanks again!

    • @taruneagles1
      @taruneagles1 6 лет назад

      Yup, join should take care of that.
      Thanks for these tutorials Corey. Really appreciate em.
      I am not as fast as the other guys, who finished these tutorials in a day or two. I am on week two. :)

    • @Leonardo200467
      @Leonardo200467 3 года назад +1

      Hey just coming here after 3y to thank you alot, lifesaver comment

  • @MmmBopsPops
    @MmmBopsPops 5 лет назад +9

    29:00 - Even though the likelihood of two 8-byte numbers being the same is astronomical, might as well check to make sure the image doesn't already exist and if so, regenerate a new hex.

    • @swordthrower
      @swordthrower 4 года назад

      Ha! When I got to that part I thought the same thing and immediately checked the comments to see if anyone else did too... Agree that it's incredibly unlikely, but better safe than sorry.

    • @BtheDUB
      @BtheDUB 4 года назад

      How would you do this? Query the DB , right just like earlier with usernames and emails?

    • @kardeslermc-berk583
      @kardeslermc-berk583 4 года назад +2

      @@BtheDUB Actually you would probably have to check the profile_pics folder with the os.listdir() function and compare them to generated hex. If the file already exists, regenerate new hex. But as been told, that's not very likely.

  • @CoinBahd
    @CoinBahd 3 года назад

    damn this tutorial series really has it all.

  • @purplefan204
    @purplefan204 Год назад +1

    Great series Corey! Can't thank you enough.

  •  4 года назад +1

    Realy impressive tutorials with legendary explanations. Thanks !!!

  • @alvinwafulalusenaka1247
    @alvinwafulalusenaka1247 5 лет назад +1

    You are the best thing that has ever happened to me! I thank you very much. Thank you for existing!

  • @josepharenas8905
    @josepharenas8905 5 лет назад

    Guess how many times I came back to this series

  • @marc-olivierblouin4709
    @marc-olivierblouin4709 6 лет назад +1

    Love the Flask-Series!! Keep it up

  • @paulmorenkov
    @paulmorenkov 5 лет назад +3

    Wow, thank you for these great videos! I mostly program as a hobby, and have had trouble finding good resources on web development, and was honestly quite intimidated, but you, as always, provide a great series!
    I have a question about the render_template() function: what determines whether or not you need to pass a variable to it? For example, `title` and `image_file` are passed in, but current_user isn’t, but still works fine in the template.
    Thank you again!

    • @brianwahome5789
      @brianwahome5789 5 лет назад

      These are all optional parameters and are autoscaled into the function as context variables. The only required parameter is the resource template which is our actual html. The rest can be left out and can be either made use of or ignored. render template is coded to be as flexible as possible hence the use of autoscaping here (**). Its why that one function works for, taking in as many parameters as needed without needing restructuring of the function.

  • @david0411
    @david0411 Год назад +3

    For those wondering how to remove the previous image from the profile_pics directory after updating the profile picture. It's just as simple as adding this line in the save_picture() function:
    - if current_user.image_file != 'default.jpg:
    os.remove(os.path.join(app.root_path,
    'static/profile_pics', current_user.image_file))
    It has be added before this line:
    - i.save(picture_path)
    Let me know if someone find another solution!

  • @Metachief_X
    @Metachief_X 5 лет назад +1

    this series is EPIC

  • @quechon1
    @quechon1 6 лет назад

    Hey man great job on the whole flask playlist

  • @luuvinhtuong4490
    @luuvinhtuong4490 5 лет назад +1

    i love your series, very helpful, very clearly, thanks so much

  • @hahaha5418
    @hahaha5418 6 лет назад +1

    Love from Bangladesh, You're so amazing...thanks Corey Schafer.

  • @aleksandrshirokov9037
    @aleksandrshirokov9037 6 лет назад +7

    great tutorial, but the puppy is amazing!!!

  • @electromorphous
    @electromorphous 4 года назад +1

    That doggo is real cute!

  • @oleksandrasaskia
    @oleksandrasaskia 4 года назад +1

    Would be super interesting to add how to auth with GMail, for instance.

  • @JoshuaBlais
    @JoshuaBlais 5 лет назад +1

    This series is awesome, thank you so much! Subbed!!

  • @SAnCtuSsBalTuss
    @SAnCtuSsBalTuss 4 года назад

    While your puppy picture was on I heard nothing you said :D In my mind only "AAAWWWWWW, CUUUUTTTEEE"!

  • @АртурРожков-в8ф
    @АртурРожков-в8ф 5 лет назад +2

    Thank you from Armenia,m you are amazing!!!

  • @OpteroNN
    @OpteroNN 4 года назад +1

    Great tutorial series! Thanks so much!

  • @ewi53890
    @ewi53890 4 года назад

    Hi Corey, Excellent video, this was extremely helpful! Can you add a quick video to show us how we can add pictures and video files to each post? I would like the user to have the ability to include photos from their desktop and add to their posts. I love that they can add photos to their profile and would like to provide the option for them to include photos within their posts as well. Thanks so much!!

  • @georgezuo4620
    @georgezuo4620 3 года назад +1

    Something that I noticed is Emails are NOT case sensitive and that should be taken into account when making a website that requires email or else people can sign up for multiple account using same email by changing capitalization their email.

  • @zaph254
    @zaph254 Год назад

    I really love the series and am really having fun, I just have one question on this module though...I thought we will be sending the images the users upload to the database, why are we sending them to the static folder? Is this how real world web apps work, or is there a way to send these images to a database.?
    Otherwise, am moving to the next module, and that is the one for creating, updating and deleting posts, Pure fun

  • @rdd9558
    @rdd9558 4 года назад +1

    very nice Corey !

  • @dhruvgupta8278
    @dhruvgupta8278 4 года назад

    Your videos are magical

  • @Dipenparmar12
    @Dipenparmar12 Год назад

    Amazing tutorial.. thank you for your efforts

  • @gamedev1380
    @gamedev1380 5 лет назад +1

    Hi Corey, not sure if you're still reading these comments. Loving the tutorials. Am up to the end of this video. Pillow is installed for PIP. Run the code and I get the following error.
    website_1 | File "/logrr/logrr/blueprints/login/views.py", line 74, in accountPage
    website_1 | picture_file = save_picture(form.picture.data)
    website_1 | File "/logrr/logrr/blueprints/login/views.py", line 57, in save_picture
    website_1 | i.save(picture_path)
    website_1 | File "/usr/local/lib/python3.7/site-packages/PIL/Image.py", line 2004, in save
    website_1 | fp = builtins.open(filename, "w+b")
    website_1 | FileNotFoundError: [Errno 2] No such file or directory: '/logrr/static/images/profile_pics/757b0bf5ed6b98cb.jpg'
    I check and sure enough, in the profile_pics folder there is no file. I changed permissions so that all users can access the folder with full access so it can't be that.
    Line 74 is calling the save function:
    picture_file = save_picture(form.picture.data)
    Line 57 is the actual save line in the function:
    i.save(picture_path)
    What could be wrong? I'm a little stumped. Thank you

    • @orcunsamitandogan
      @orcunsamitandogan Год назад

      Hey, I know time passed but it worths to ask. I have same problem and tried same things. Have you found any solution?

    • @orcunsamitandogan
      @orcunsamitandogan Год назад

      Now I solved. Problem is this: when we delete the first section of the file, we also delete the name of uploading* object. However, we need it. File we download has also hex-like naming. In fact, we need first and second section of life. My solution for this deactivate the random_hex. In this way, I was able to upload it. However, I am not sure, what kind of security issue it can cause.
      f_first, f_ext = os.path.splitext(form_picture.filename)
      picture_fn = f_first + f_ext
      With this, I am able to upload a new picture.

  • @anildhage
    @anildhage 3 года назад

    Hello Sir,
    I have a question for you. You have a great experience with python and flask before creating this playlist, I want to know your approach on this topic. Before creating this project in this playlist, how much time did you take to get this fluency in the flask model? How many projects do you recommend I to create and build to get this kind of fluency. Your answer will motivate me.
    Great content by the way, I am learning a lot from you. Thank you for your effort on this.

  • @jaideepadhvaryu9642
    @jaideepadhvaryu9642 5 лет назад

    Once again, every video is excellent. Thank you for your effort and offering to rest of us. Few questions:
    - I am planning to use Google App Engine + Python 3 + Flask. Will this work?
    - Also, i want to use GCP's datastore and upcoming firestore. Since we are using sqlalchemy, will it work out of box?
    - do you have similar example of using Firebase's user authentication.

  • @aifsssm
    @aifsssm 5 лет назад +1

    superb tutorial! thank you very much man.

  • @brumleblichfeldt4025
    @brumleblichfeldt4025 2 года назад

    Love these videos, easy to follow and of just the right length. :) Have a question tho... when I upload a .jpg the orientation changes, is it possible to add some code to prevent that?

  • @madhuriprasad5416
    @madhuriprasad5416 4 года назад

    Really very nice tutorials Corey. Went through all your videos Django, Flask . Thank you. Hope you would reply my question:
    How you will know that you need that form or anything to imported if it’s by going through documentation how you manage to go through all the content because one page leads to many sub topics? I really wish you could reply or make a video on this . Thank you once
    again 😊.

  • @mvi6039
    @mvi6039 4 года назад

    Your dog is lovely!

  • @amiraslanbakhshili5420
    @amiraslanbakhshili5420 5 лет назад +1

    Thank you! Incredible content, loved it

  • @wingielee
    @wingielee 5 лет назад +1

    impressive and analogical.....

  • @Daiphiron
    @Daiphiron 4 года назад

    I really love your tutorials. This series specially helps me a lot. But man ... i usually play tuts with 1.25 even as non native english speaker .. but you are that fast o0

  • @headlessdonkey01
    @headlessdonkey01 5 лет назад

    great video, really helped me understand some cool tricks with flask. Corey, i was wondering if you could give an example of how to remove the image files from the file directory upon updating profile picture. Thanks again

  • @mouradelcadi
    @mouradelcadi 4 года назад

    thank you so much sir you are the best i think this channel is the best , really great content

  • @habib-urrehman3094
    @habib-urrehman3094 5 лет назад +1

    great work, amazing help.

  • @aakashtiwari3974
    @aakashtiwari3974 4 года назад +1

    Talented Corey Thanku

  • @kchemutai3483
    @kchemutai3483 5 лет назад +1

    This Videos Really make Programming easy. Thanks Corey for the great content. Do you have a Link of the Django version of this content

  • @h82fail
    @h82fail 6 лет назад

    Decided on Part 3 when I noticed all the repeated/copy and pasted code in the register.html, especially after putting in the if errors code I was going to keep it DRY and find a better way. Now after doing the account form as well I have made it really cleanly.
    In register.html, login.html, account.html in place of ...... I just put {% include 'includes/_form.html' %}
    Then I made a includes/_form.html:
    {{ form.hidden_tag() }}
    {{ form_title }}

  • @jean-charlesb.7360
    @jean-charlesb.7360 6 лет назад +1

    Great videos! Thank you very much!

  • @jiandeng8595
    @jiandeng8595 6 лет назад

    @13:35, we can use `ctrl+shift+;` to delete the html tag in sublime

  • @Lucas-qr7ul
    @Lucas-qr7ul 4 года назад

    There is a problem if we have more than one account in the system.
    I was having an issue where I was uploading a picture to my profile but it was displaying the same picture uploaded to all users. The problem was that I was passing the variable image_file to the template set to current_user, like this:
    "image_file = url_for(
    'static', filename='img/profile/' + current_user.image_file)"
    To solve it I added to my route so I could get the user id from the navbar (I had to add a variable "user_id=current_user.id" in my layout.html). I passed the parameter called "user_id" into the "account" function and defined a "user" variable then I used this "user" instead of "current_user" in the "image_file". However, I also had to pass "user_id=current_user.id" back when I redirected the page, like so:
    layout.html
    Account
    routes
    "@app.route("/account//", methods=["GET", "POST"])
    def account(user_id):
    user = User.query.filter_by(id=user_id).first_or_404()
    ....
    .....
    return redirect(url_for("account", user_id=current_user.id))
    image_file = url_for(
    'static', filename='img/profile/' + user.image_file)"
    In case anyone runs into this problem.

  • @joelexperienced
    @joelexperienced 2 года назад

    your puppy is beautiful

  • @jonathanthurgood5558
    @jonathanthurgood5558 3 года назад +1

    At about 28:22 Corey mentioned that the Secrets module has been used earlier in the series, but I'm totally blanking on that. Can anyone be a bro and let me know which video and rough time that was?

    • @11irishjs51
      @11irishjs51 3 года назад +1

      It was in Part 3 at about 11:00 minutes. We used it to generate a random string of characters for our secret key.

  • @atharvahiwase1574
    @atharvahiwase1574 4 года назад +1

    I did exactly what you did on tutorial but even after uploading the picture it doesn't appear on the account page

  • @flywitjesus
    @flywitjesus 5 лет назад

    Hello. Thank you for this series, it was helpful. One question though, can you give a clue about how to clean old profile picture when user changes one. What I think to do is to grab user's profile picture's name, look for it in profile_pics directory and, if found, delete it. Besides that, I am thinking of creating a "job" to make this stuff async. What are your thoughts about that?

  • @Linux4Ever2011
    @Linux4Ever2011 6 лет назад

    Since we generate random names for pictures, there should be a possibility that the algorithm will generate the same random name twice, correct?, and by that we could accidently delete the old picture?!
    Or the algorithms will never generate the same random names until it 'exhausts' every possible value that could be formed using eight characters?
    Thank you for the great series, please keep uploading high quality videos :) .

    • @coreyms
      @coreyms  6 лет назад

      There is a "chance", but that chance is very very very small. We could add some code that checks if an image already exists or is in use, but the chance of colliding names is so small I don't think it's worth it. If the website was going to have millions of users uploading millions of pictures then it would probably be worth it to address possible collisions.

    • @Linux4Ever2011
      @Linux4Ever2011 6 лет назад

      Thank you for the explanation :) .

  • @imagg3169
    @imagg3169 6 лет назад

    Awesome tutorial. I have a doubt regarding the validation. In case I don't have user authentication feature, won't the updating method fail on validation because you can't check if the current field is getting updated or not(due to duplication check).

  • @saidkarimsaidmahmudov3048
    @saidkarimsaidmahmudov3048 6 лет назад

    Well, Thank you ... You are doing very well series , everything is clear and easy to follow... And I have one questiong concerning the image resize ::: What if the ration of a picture uploaded is not 1x1 ... Can we set dynamic size ? (not just 125px to 125px)

  • @mojostrowinsky5235
    @mojostrowinsky5235 4 года назад

    Amazing. Thank you so much!

  • @panostheodoropoulos9202
    @panostheodoropoulos9202 4 года назад

    Hey Corey, awesome videos mate!! Quick question, why aren't the images saved in the Database with all the other user info, and they are stored inside the app directory?

    • @xtrzne
      @xtrzne 2 года назад +1

      DUDE! Ive been trying to figure this out myself xD The app seems to never send the image file to the database, instead only the filename is sent. The app loads the image from the local file system, which is a problem when logging in with foreign devices? Am I mistaken?

  • @kavabangaungava
    @kavabangaungava 6 лет назад +1

    It's cooler than the series from Game of Thrones

  • @noureddineettayyeby5210
    @noureddineettayyeby5210 4 года назад +1

    Thank you