Python Django Tutorial: Full-Featured Web App Part 9 - Update User Profile

preview_player
Показать описание
In this Python Django Tutorial, we will be finishing our user profile page. The final page will allow users to update their information and also add a new profile picture. We will also learn how to resize this image when it is uploaded to save space on our web server. Let's get started...

The code for this series can be found at:

✅ Support My Channel Through Patreon:

✅ Become a Channel Member:

✅ One-Time Contribution Through PayPal:

✅ Cryptocurrency Donations:
Bitcoin Wallet - 3MPH8oY2EAgbLVy7RBMinwcBntggi7qeG3
Ethereum Wallet - 0x151649418616068fB46C3598083817101d3bCD33
Litecoin Wallet - MPvEBY5fxGkmPQgocfJbxP6EmTo5UUXMot

✅ Corey's Public Amazon Wishlist

✅ Equipment I Use and Books I Recommend:

▶️ You Can Find Me On:

#Python #Django
Рекомендации по теме
Комментарии
Автор

There is an issue with the code in this video that I fixed in the later videos. If you're getting an error that says something like "save() got an unexpected keyword argument 'force_insert'" then please update the save method in users/models.py to the following:
def save(self, *args, **kwargs):
super().save(*args, **kwargs)

coreyms
Автор

That enctype at 6:45 screwed me up real good for 4 days trying to debug the program. I'm glad Corey pointed it out. Thanks Corey.

sambegstha
Автор

Been involved in software development for over 30 years and wanting to "build again" on my own and I have to say these tutorials are really awesome!

ChristopherGeorge
Автор

The dog in the picture is the loveliest <3 ^_^

ninonazghaidze
Автор

This series is incredible, thank you Corey :) I think the enctype thing at 7:35 needs a special emphasis. I spent 30 minutes trying to figure out why the username and email updated fine, but the image wouldn't. Putting this here to hopefully save someone the headache.

martianmatt
Автор

For blog author image, I just copied the line from users/profile.html and changed the class from account-img to article-img, that too worked. Thanks great explanation

vp
Автор

Corey is so amazing, he anticipates the sections where you could make a mistake. For me I misspelled 'multipart' to mutipart and there was no error but the uploaded image wasn't getting updated. Got back to video and found out he advised about the same trap.

shashanksharma
Автор

best teacher ever . dude you explained every little thing so clearly !! love from india

sahilbisht
Автор

I was trying to make a change to my website. For the last 5 days, I have just wanted to add an image field in my blog, but when I tried to update my Image it won't change today I saw at 7:33 that I want to add an enctype in the form tag. I applied that changes in my HTML file and it works. Thanks a lot, Corey Schefar

letsfixedit
Автор

16:40 The Highlight of my morning. Thank you

zeroXverse
Автор

I have completed this part too, really good explanation, now i just have few videos remaining, also i'm coding along, so it's a great experience

theinnoverse
Автор

You are The G.O.A.T. ...Your explanation is inch-perfect

dennischirchir
Автор

You are the best teacher for django out there. You teach professionally 👍👍

ishankamboj
Автор

This is the most useful tutorial I encountered while learning Django. Excellent stuff. 1 small suggestion for the above lesson:

Instead of having this twice in views.py:

u_form = UserUpdateForm( instance=request.user ) (for GET)
u_form = UserUpdateForm( request.POST, instance=request.user ) (for POST)

This can be done in 1 line like this:

u_form = UserUpdateForm(request.POST or None, instance=request.user)

waqasmushtaq
Автор

You have saved me from failing this class 😭 Subbing for sure, thank you

AstronautKanojo
Автор

Using this tutorial to catch up with Django for a School Project.. hahaha even with the depricated methods by post date Django 5.0, I still love the learning path and word choice for explanation.. THumBs Up

callmeetc
Автор

Thank you so much Corey Schafer for your Tutorials ....its really really Helping me ..No words to describe it

JayaPrakash-iore
Автор

Words can't explain how much i want to thank you for this awsome tutorial

htfihottopicfeed
Автор

Corey, you're a legend, thank you so much!
Just a small thing that can help; maybe it will be better if you'll use keyword arguments more often because it helps clarify what is the meaning of every argument we pass.
For instance, in the profile function inside the views.py module, we can also write it like this:

def profile(request):
# u_form = user_form, p_form = profile_form
if request.method == 'POST':
u_form = UserUpdateForm(data=request.Post, instance=request.user)
p_form = ProfileUpdateForm(data=request.Post, files=request.FILES,
else:
u_form =
p_form =

And then it is much more readable.

yehonatan
Автор

Corey is great...however, in this video he's using square images to make those perfect circle avatar thumbnails. If you try a non-square image, it will looked kind of skewed. if you want to resize by middle crop to his dimensions. use this... in models.py import an additional Pillow function:
From PIL import Image, ImageOps


then later in the function def save

if img.height > 300 or img.width > 300:
output_size = (300, 300)
resized = ImageOps.fit(img, output_size, Image.ANTIALIAS)
resized.save(self.image.path)


this basically crops the image to 300x300 square so that the circle bootstrap and css he provided work.

Sirreal