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

  Рет қаралды 289,951

Corey Schafer

Corey Schafer

Күн бұрын

Пікірлер: 672
@coreyms
@coreyms 6 жыл бұрын
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)
@jstone1cougar
@jstone1cougar 6 жыл бұрын
@21:05 files from my photos on my mac were 180 askew so: img.rotate(180)
@anneest
@anneest 6 жыл бұрын
Ah thanks, I got this error and I was going to comment here. Now it works smoothly. Great! :-)
@arfin97
@arfin97 6 жыл бұрын
Can you please tell me how do I stop saving duplicate images with new name? If an image I'm uploading is from the same user, it will delete the previous image of the user and save the new one. How can I do that? Btw, thanks for such awesome tutorials :)
@varunmahanot5766
@varunmahanot5766 6 жыл бұрын
all of my flash messages are going to the admin page
@Tedraketje
@Tedraketje 6 жыл бұрын
@@jstone1cougar same problem but then 90degrees to the right. but img.rotate(-90) doesn't seem to do anything. I pasted my code here. if img.height > 500 or img.width > 500: output_size = (500, 500) img.thumbnail(output_size) img.rotate(-90) img.save(self.image.path)
@sambegstha1241
@sambegstha1241 5 жыл бұрын
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.
@ChristopherGeorge1964
@ChristopherGeorge1964 5 жыл бұрын
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!
@martianmatt392
@martianmatt392 3 жыл бұрын
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.
@shubhamsirothiya2551
@shubhamsirothiya2551 3 жыл бұрын
My image is not updating
@ebvogt111
@ebvogt111 2 жыл бұрын
@@shubhamsirothiya2551 ensure to be using correct file format (.jpg) and not some random PDF or something.
@ninonazghaidze7687
@ninonazghaidze7687 5 жыл бұрын
The dog in the picture is the loveliest
@erwinnovo3014
@erwinnovo3014 Ай бұрын
These videos just keep on getting better and better! Kudos, Corey!
@letsfixedit572
@letsfixedit572 2 жыл бұрын
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
@shashanksharma7242
@shashanksharma7242 4 жыл бұрын
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.
@daphinebabu4614
@daphinebabu4614 3 жыл бұрын
couldn't agree with you more.. corey is incredible!
@nmoore1988
@nmoore1988 3 жыл бұрын
Just made the same mistake, thanks for this comment, made me look again.... I mistyped and ended up with 'ecntype'
@vp9041
@vp9041 6 жыл бұрын
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
@thewordforever4839
@thewordforever4839 5 жыл бұрын
No that doesn't work. It will always show the picture of the user who is logged in, not the actual author of the post
@sahilbisht3661
@sahilbisht3661 4 жыл бұрын
best teacher ever . dude you explained every little thing so clearly !! love from india
@zeroXverse
@zeroXverse 5 жыл бұрын
16:40 The Highlight of my morning. Thank you
@yehonatan3000
@yehonatan3000 Жыл бұрын
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, instance=request.user.profile) else: u_form = UserUpdateForm(instance=request.user) p_form = ProfileUpdateForm(instance=request.user.profile) And then it is much more readable.
@theinnoverse
@theinnoverse 4 жыл бұрын
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
@ThienNguyen-up3ks
@ThienNguyen-up3ks 4 жыл бұрын
have u get a programming job?
@theinnoverse
@theinnoverse 4 жыл бұрын
@@ThienNguyen-up3ks nope it's hard in lockdown, I'm looking for a job
@waqasmushtaq81
@waqasmushtaq81 4 жыл бұрын
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)
@dennischirchir5461
@dennischirchir5461 5 жыл бұрын
You are The G.O.A.T. ...Your explanation is inch-perfect
@tyler-taewook
@tyler-taewook 3 жыл бұрын
If your form is working fine but the image isn't being updated, make sure to check you haven't misspelled anything from [enctype="multipart/form-data"] in .html file! I made a typo here which caused the exact same problem, which seems many have also encountered in this comment section
@alimoradi8490
@alimoradi8490 Жыл бұрын
Thanks bro😂😂😂😂
@TimLin-ui7kp
@TimLin-ui7kp 11 ай бұрын
thank you
@friendlychannel100
@friendlychannel100 4 жыл бұрын
i am on tutorial 9 and realised i am not a sub yet!... Thank you for this amazing series so far... i went through lots of tutorials but none of them go the ways you do. 💕 will support you when i am able to ✌
@adaymunizrosas9486
@adaymunizrosas9486 4 жыл бұрын
How proud can one be of his dog? I do the same with mine xD
@ishankamboj3522
@ishankamboj3522 4 жыл бұрын
You are the best teacher for django out there. You teach professionally 👍👍
@ronnymokaya6124
@ronnymokaya6124 Жыл бұрын
If you're having an issue resizing the image and getting the error Image is not defined, you can try import pillow library "from PIL import Image" and it will work right.
@AstronautKanojo
@AstronautKanojo 10 ай бұрын
You have saved me from failing this class 😭 Subbing for sure, thank you
@callmeetc
@callmeetc 9 ай бұрын
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
@mr.anderson5393
@mr.anderson5393 4 жыл бұрын
I have to say thank you very much for the great tutorial. I recreated users app and watched part 6-8 several times, and finally able to do parts 6-8 without watching the tutorial. However, part 6-8 is not a joke- I studied basic OOP, but not like this. Luckly, Mr. Schafer, sir you have explained thigs pretty well for me to understand. Once again great tutorial and thank you very much.
@callmeetc
@callmeetc 9 ай бұрын
Hahaha, kept on getting the logour error and got stuck through the very same episodes two day in a row now.... now we off to 9
@mr.anderson5393
@mr.anderson5393 9 ай бұрын
@@callmeetc you cool now?
@ksjempire1957
@ksjempire1957 5 жыл бұрын
You must get a lot of watchtime from these you deserve all those minutes and more
@thetruereality2
@thetruereality2 4 жыл бұрын
Hi Corey, I have been following your tutorials from the beginning and I understand your explanation quite well. Thank you very much for posting these videos.
@Sirreal45
@Sirreal45 5 жыл бұрын
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.
@dcdemeo
@dcdemeo Ай бұрын
Five years later, Image.ANTIALIAS is deprecated. Use Image.LANCZOS instead.
@ΠΑΝΟΣΚΩΣΤΟΠΟΥΛΟΣ-η3χ
@ΠΑΝΟΣΚΩΣΤΟΠΟΥΛΟΣ-η3χ 5 ай бұрын
there is a mistake here i think. the signals interfere with the views and the save method from Profile is called twice when updating the profile(you can check it yourselves by putting a print statement) i fixed by by removing the 2nd signal save_profile as the save method is always being called from the views. also the overrided method needs args and kwargs because the parent function (super) needs them to function.
@kristiyanpenev1820
@kristiyanpenev1820 2 жыл бұрын
Mr. Corey, you are simple THE BEST!
@djudsod959
@djudsod959 4 жыл бұрын
16:30 the dog is adorable. Instantly Paused the tutorial to mention this.
@bunchathumbs6194
@bunchathumbs6194 3 жыл бұрын
If ur watching this course and you are beginner I would recommend you to start with learning Flask first. Yeah Django is amazing but to much stuff if working out of the box. P.S. Tutorial is great!
@jacobshore
@jacobshore 5 жыл бұрын
Hi, thanks for these videos, they're great! Quick question/clarification: the reason we were able to access the image from the homepage via {{ post.author.profile.image.url }} is because the author column of the post table is a foreign key to the user username table as set in the blog app models + the profile has a one to one relationship with the the user table as set in the user app models - right? It seems kind of intuitive, but I'm looking through the docs to see what would work with this and what wouldn't and I get the sense that in the other frameworks I've experienced (mostly PHP ones like Laravel, Symphony, Yii + Flask) one would have to be much more explicit about these connections - but maybe it's just intuitive b/c you're so smooth and make it seem so obvious. If you, or anyone reading this, could lead me the right documentation, I'd greatly appreciate it.
@junecnol79
@junecnol79 4 жыл бұрын
10:25 ModelForm 기존의 model의 이용하여 form 만들기 docs.djangoproject.com/en/3.0/topics/forms/modelforms/#modelform 11:30 HttpRequest.POST 안에 사용자가 입력한 form data가 들어있다. docs.djangoproject.com/en/3.0/ref/request-response/#django.http.HttpRequest.POST 12:15 HttpRequest.FILES 12:50 multi form validation 17:29 resizing image with pillow 18:25 Model.save() docs.djangoproject.com/en/3.0/ref/models/instances/#saving-objects 24:50 bootstrap rounded-circle article-img
@bowenwang
@bowenwang 6 жыл бұрын
Too great to stop watching.
@OmarSanchez-ds4qh
@OmarSanchez-ds4qh 6 жыл бұрын
started at 11AM and its 4AM now. just too good.
@boryskuczkowski
@boryskuczkowski 6 жыл бұрын
Hey Corey, after testing the app, I encountered the problem while trying to register new user - save() got an unexpected keyword argument 'force_insert'. I came around it by adding **kwargs into the Profile save function: def save(self, **kwargs): super().save() img = Image.open(self.image.path) if img.height > 300 or img.width > 300: output_size = (300, 300) img.thumbnail(output_size) img.save(self.image.path) Is that ok in your opinion?
@mishatet8911
@mishatet8911 6 жыл бұрын
That was actually my case. So, thanks for the tip.
@dikdikoobraz2875
@dikdikoobraz2875 6 жыл бұрын
I had the same problem
@daksh_sagar
@daksh_sagar 6 жыл бұрын
Signature of the base method in class Model is save(self, **kwargs) and method overriding it should have the same signature, so adding **kwargs as an argument to save makes sense.
@nasalee3729
@nasalee3729 6 жыл бұрын
I have the same issue too, and this solved the problem!!
@azamuray
@azamuray 6 жыл бұрын
Thank you
@htfihottopicfeed9734
@htfihottopicfeed9734 3 жыл бұрын
Words can't explain how much i want to thank you for this awsome tutorial
@JayaPrakash-io2re
@JayaPrakash-io2re 5 жыл бұрын
Thank you so much Corey Schafer for your Tutorials ....its really really Helping me ..No words to describe it
@banaras.wala.foreignaala
@banaras.wala.foreignaala 4 жыл бұрын
Hi Corey, So far so good, you explained it very well, thanks
@pipinstallpython
@pipinstallpython 6 жыл бұрын
I'm in love with your coding, thanks for the quality videos so much useful information.
@roba_mutua
@roba_mutua 5 жыл бұрын
Great tutorial. In the resizing of the images, how about instead of overwriting the save method, we resize the image before committing the form? Something like: if profile_picture_form.is_valid(): instance = profile_picture_form.save(commit=False) img = Image.open(instance.profile_picture.path) if img.height > 400 or img.width > 400: output_size = (400, 400) img.thumbnail(output_size) img.save(instance.profile_picture.path) instance.save()
@pawanchhangani7528
@pawanchhangani7528 5 жыл бұрын
You are awesome ❣️ my friend. Love from India
@mihaly-wm9tb
@mihaly-wm9tb Жыл бұрын
After resizing the image, it is rotated 90 degrees anticlockwise. To fix that, one can use the built-in rotate method of the Image class in the pillow package. See below code with rotate() being applied to the resized image. if img.height > 300 or img.width > 300: output_size = (300, 300) img.thumbnail(output_size) img = img.rotate(-90) img.save(self.image.path)
@hidayathidayat4469
@hidayathidayat4469 3 жыл бұрын
can't believe this is free on youtube
@mdminhajulislammahin9510
@mdminhajulislammahin9510 3 жыл бұрын
Awesome Tutorial Thanks Sir. Take love from Bangladesh
@PradeepKumar-ps4cs
@PradeepKumar-ps4cs Жыл бұрын
I wasn't able to make crispy forms work my django so I removed crispy tags and all crispy references. On profile page, I can see image, username and email but u_form and p_form (input fields) are not showing up in the browser. Yes, {{ u_form }} and {{ p_form }} are included on profile.html
@PradeepKumar-ps4cs
@PradeepKumar-ps4cs Жыл бұрын
I found the issue, I didnt add context to the render in the last line. After adding ut worked. I compared Corey's code and mone line by line.
@toastrecon
@toastrecon 5 жыл бұрын
Another great one. Thanks, Corey!
@moebazzi8412
@moebazzi8412 6 жыл бұрын
AMAZING AND CLEAR TUTORIALS WELL DONE COREY!!!
@congcuongnguyen413
@congcuongnguyen413 2 жыл бұрын
0:25 - form to update profile 3:28 - view to update profile 4:54 - template 7:13 - enctype attribute 9:20 - model form 11:11 - pass in POST data 16:41 - auto resize image 23:27 - display author image in post
@sabmost
@sabmost 2 жыл бұрын
Pls send the source
@yongxuanch2930
@yongxuanch2930 4 жыл бұрын
hello there corey, you're videos are amazing, I just want to let you know that after I followed the video my accounts suddenly went wrong so I just want to say that I added this code : def save(self, *args, **kwargs): super(Profile, self).save(*args, **kwargs) img = Image.open(self.image.path) if img.height > 300 or img.width > 300: output_size = (300,300) img.thumbnail(output_size) img.save(self.image.path)' and everything went totally fine.
@RebeccaBrunner
@RebeccaBrunner 6 жыл бұрын
Great series so far, thorough but simple.
@AlwarrenSidh
@AlwarrenSidh 6 жыл бұрын
Great video series, I am thoroughly enjoying this.
@zebusaqua4415
@zebusaqua4415 2 жыл бұрын
updated save function with delete included. Also does not accidentally delete the default.jpg image def save(self, *args, **kwargs): try: this = Profile.objects.get(id=self.id) if this.image == 'default.jpg': pass elif this.image != self.image: this.image.delete(save=False) except: pass super(Profile, self).save(*args, **kwargs) img = Image.open(self.image.path) if img.height > 300 or img.width > 300: output_size = (300, 300) img.thumbnail(output_size) img.save(self.image.path)
@arcadioabrahamherreraabril7606
@arcadioabrahamherreraabril7606 3 жыл бұрын
That is an incredible content! Greetings from Spain
@romann_shr
@romann_shr Жыл бұрын
VS code is more convenient to me than sublime text since it shows the related functions while typing, so we don't make any typos
@xvegandersx
@xvegandersx 6 жыл бұрын
First of all, great tutorials, I've been binge-watching them since this morning. Secondly, I've run into a really weird bug or behavior I do not understand when resizing the images. At first my images wasn't being resized properly so I sprinkled some logging in the save function of the Profile class. Just before the if-statement I logged both img.width as well as self.image.width and the two differed, with the former set to the limit of 300, while the latter had the original size. I then continued to add more logging and added an else statement to make it something like this: needs_resize = img.width > 300 or img.height > 300 logger.error(f'{img.width}x{img.height} {needs_resize}') logger.error(f'{self.image.width}x{self.image.height}') if needs_resize: logger.error("In resize before work") output_size = (300, 300) img.thumbnail(output_size) img.save(self.image.path) logger.error("In resize after work") else: logger.error("No resize needed") The weird thing is that as the above is written, I will get this output: 190x300 False 515x812 No resize needed If I on the other hand comment out the line img.save(self.image.path) I will get this output: 515x812 True 515x812 In resize before work In resize after work Any clue on what's going on? It seems like the img.save function gets called before the if-statement is evaluated somehow.
@xvegandersx
@xvegandersx 6 жыл бұрын
I should just add that the resizing seems to work, but the logging is still incorrect
@taoufikb597
@taoufikb597 5 жыл бұрын
@@xvegandersx super().save() ?
@anatoliyloboda4601
@anatoliyloboda4601 5 ай бұрын
Thank you Corey! But it turns out the small issue. If default imange is updated it is saved into media/profile_pick. So if a user updates their profile multiple times, the old images won't be deleted and the save capacity won't be vacant
@GCKteamKrispy
@GCKteamKrispy Жыл бұрын
Hey guys. I am very confused on this question: why do we register and update users AND profile? Aren't they same?
@ingafter6335
@ingafter6335 3 жыл бұрын
Hi Corey, Many-many thanks for this great and practical tutorials. I have learned a lot from this tutorials. About resizing the image, please advise me to learn more about it. Thanks. Nyoman, from Bali, Indonesia
@lightflix
@lightflix 5 жыл бұрын
Hey Corey, your tutorials are great!! The images are not proportional inside the circle so how can we fix that? If I upload an image that's not equal in height and width, it gets stretched. Thank you
@austinpena7859
@austinpena7859 5 жыл бұрын
object-fit CSS rule
@ModularPilotJack
@ModularPilotJack 2 жыл бұрын
If you're watching this in 2022, go profile.html, in the first img class (where profile url is linked) add style="border-radius= 50%" before src="". That will make it a circle :) edit: to make it look less stretched, make sure the HTML class points to the css div account-image
@banaras.wala.foreignaala
@banaras.wala.foreignaala 4 жыл бұрын
Oh my god, super().save() this is really super Awesome. So far so good. Thanks
@georgedikas7327
@georgedikas7327 Жыл бұрын
Hello Corey! Why did you write self.image.path instead of writing self.image.url within overriden save method? Thank you in advance!
@Rahul-ut9rd
@Rahul-ut9rd 3 жыл бұрын
We actually don't need to add email field explicitly in UserUpdateForm. As User model already has an email field. We can convert email field from User to model to form field just like username field
@bringinglife2
@bringinglife2 4 жыл бұрын
This is just excellent! Thanks a lot for the content!
@wladimirovff
@wladimirovff 4 жыл бұрын
Thanks a lot for the course, it's amazing , you are really a good teacher :-D
@WajidAli-mf2yk
@WajidAli-mf2yk 5 жыл бұрын
Hi, Corey, This is an amazing series. I really want to change my tech stack. ( from java to python)
@danielflorez3762
@danielflorez3762 2 жыл бұрын
Please, dont. Django is so f-ing complicated.
@LukaReeson
@LukaReeson 3 жыл бұрын
For anyone how wants to delete the old profile image when you upload a new one: 1. pip install django-cleanup 2. in settings.py INSTALLED_APPS = ( ... 'django_cleanup', # should go after your apps )
@arturofm
@arturofm 6 жыл бұрын
around minute 4:40 your speed was like looool jajajaj I had to pause the video like 5 times :D
@coreyms
@coreyms 6 жыл бұрын
Haha. You can set the speed to 0.75 if it helps.
@tipstoeveryoneblogspot2989
@tipstoeveryoneblogspot2989 4 жыл бұрын
I got this error when I try to access the admin page: RelatedObjectDoesNotExist at /admin/login/ after doing bit research found solution as below.: file: users/signals.py from django.core.exceptions import ObjectDoesNotExist @receiver(post_save, sender=User) def create_profile(sender, instance, created, **kwargs): try: instance.profile.save() except ObjectDoesNotExist: Profile.objects.create(user=instance)
@vladusa
@vladusa 4 жыл бұрын
its already correct for everyone
@nihal2252
@nihal2252 4 жыл бұрын
Thank you @tipstoeveryone blogpost. Even StackOverflow was not able to solve my problem. :p Thanks a lot.
@sripriyar3916
@sripriyar3916 4 жыл бұрын
Dude thank you very much!! Had a prob with class based update view so had to use Post function in my CBV !
@kiranraj-dw5gq
@kiranraj-dw5gq 5 жыл бұрын
Thanks Corey.Awesome Tuts
@JohnDoeJr123
@JohnDoeJr123 6 ай бұрын
At 15:47 I had an interesting error. When trying to login as admin to /admin I had 'user profile does not exist' error. As a solution I had to manually insert record about admin to users_profile table with values for id, image, user_id columns.
@ildar_eto_ya
@ildar_eto_ya 2 жыл бұрын
Really love it!
@nickwinnenberg9109
@nickwinnenberg9109 4 жыл бұрын
That's a really, really cute puppy.
@sumit180288
@sumit180288 4 жыл бұрын
If I put an existing username while updating profile page, then {{ user.username }} is showing incorrect value in profile.html, even though save() is not called. Can you please help with that.
@jeisaraja9851
@jeisaraja9851 3 жыл бұрын
Yes i need help on this too
@vicentemanriquez5166
@vicentemanriquez5166 5 жыл бұрын
Any one have problems with crispy and profile form ? i don´t have the same button to upload the image and dont show the previous url image, help :C
@tomatoft.02
@tomatoft.02 2 жыл бұрын
Great tutorial, but i don't understand where profile is in request.user.profile at 10:28
@bishalgautam3874
@bishalgautam3874 6 жыл бұрын
Great tutor! Keep making such videos
@ishantiwarimusic
@ishantiwarimusic 4 жыл бұрын
Which laptop do you use
@briansf24
@briansf24 9 ай бұрын
Is email = forms.EmailField() required in the UserUpdateForm class? I understand why we included it in UserRegisterForm - email isn't a default field in UserCreationForm. But seems like we're not modifying the behavior of the email field in any way so the Meta class definition should be enough so long as we include both username and email?
@sinmiakindele266
@sinmiakindele266 5 жыл бұрын
Thank you so much for your videos, they have been so helpful in my understanding of django. I was wondering if you can help me with debugging, anytime I log in with a new user and try to access his profile, i get this error message; "RelatedObjectsDoesNotExist at /profile/" but I'm able to access profile with only the first two test users that I created, I get that error message with other test users.
@stasczekalski3436
@stasczekalski3436 6 жыл бұрын
I was having an issue of not seeing authors' profile pictures next to their posts. It turned out the posts were created by users for which I havn't uploaded pictures (and they havn't been uploaded by default, because these users were created before loading default image functionality had been implemented). Be careful not to make the same mistake I did!
@gyappumusoka4016
@gyappumusoka4016 5 жыл бұрын
I literally just had the same problem now! I came here to look for answers and here you came. Thanks! I haven't even paid attention to that.
@xintongliu8068
@xintongliu8068 4 жыл бұрын
1. create update userform and update profile form to the profile page. 2. resize oversize imported ing. 3. add author's img to the post.
@manikndn8
@manikndn8 6 жыл бұрын
Wonderful Corey!
@shashwatpandey3556
@shashwatpandey3556 4 жыл бұрын
I followed up till 8:30 and then I checked up on my server it was fine too but when loaded the profile page from the site it showed an error and said "ModelForm has no model class specified. " pls anyone Help ME out...
@sos2271
@sos2271 4 жыл бұрын
change meta to Meta in forms.py
@shashwatpandey3556
@shashwatpandey3556 4 жыл бұрын
@@sos2271 did that but the code failed...
@shashwatpandey3556
@shashwatpandey3556 4 жыл бұрын
@@sos2271 Exception has occurred: ImproperlyConfigured Creating a ModelForm without either the 'fields' attribute or the 'exclude' attribute is prohibited; form ProfileUpdateForm needs updating. File "C:\Users\VC\Documents\practice\Schaffer\ODIN\users\forms.py", line 22, in class ProfileUpdateForm(ModelForm): File "C:\Users\VC\Documents\practice\Schaffer\ODIN\users\views.py", line 4, in from .forms import UserRegisterForm, UserUpdateForm, ProfileUpdateForm File "C:\Users\VC\Documents\practice\Schaffer\ODIN\ODIN\urls.py", line 19, in from users import views as users_views I used the Django debugger and that's what it said.
@sos2271
@sos2271 4 жыл бұрын
@@shashwatpandey3556 i think you missed something restart video and watch it step by step , i had the same probleme at the first but when i changed meta to Meta it worked
@shashwatpandey3556
@shashwatpandey3556 4 жыл бұрын
@@sos2271 possibly
@stephendocherty1203
@stephendocherty1203 Жыл бұрын
Loving these tutorials, thank you so much! Noticed a couple of issues with this one however. Fistly, when uploading some image files after implementing the resizing method, it is rotating image through 90 degrees. Also noticed that it doesn't delete the old profile image from the profile_pics folder. Would appreciate any feedback on both issues please.
@scottyleitzke6498
@scottyleitzke6498 5 жыл бұрын
When following this tutorial, I couldn't get my u_form or p_form to appear on the profile page, just the update button, picture, and the box outline. Any help would be appreciated
@rozhanynzn8207
@rozhanynzn8207 5 жыл бұрын
i think you haven't pass variables i.e {{ u_form|crispy }} {{ p_form|crispy }} in profile.html file or in forms.py check your class Meta see its uppercase meta M should be capital letter
@rosssymonds
@rosssymonds 5 жыл бұрын
@@rozhanynzn8207 I have just checked and I have written meta with a capital M.
@jamesmiddleton5114
@jamesmiddleton5114 5 жыл бұрын
@@rosssymonds I am a dumbass after scrolling over the code for an hour I realised I had forgotten to pass context as an argument in the return statement return render(request, 'users/profile.html', context). Hope this helps!
@inodecode7600
@inodecode7600 5 жыл бұрын
@@jamesmiddleton5114 omg that fixed mine, thanks brooo
@clare9762
@clare9762 4 жыл бұрын
@@jamesmiddleton5114 Did the same thing, thanks!
@g3org3210
@g3org3210 4 жыл бұрын
A couple of issues i've got: 1. next to 'Currently: image path/name etc.' i get a tick box that says 'Clear' which if ticked and then submitted will through an error : 'The Profile could not be changed because the data didn't validate.' 2. if i drop a picture in the 'media/profile_pics' and the update with that one would save me another resized picture/file with a suffix type naming on the end instead of overwriting the original just with the new size and keep the naming; i.e if i were to upload the same image over and over i'd get multiple files with a different naming suffixed. Thanks for the course Corey.
@theglammcoder
@theglammcoder 4 жыл бұрын
Same problem whenever i click on clear it shows an image attribute error
@theglammcoder
@theglammcoder 4 жыл бұрын
Same problem whenever i click on clear it shows an image attribute error
@theglammcoder
@theglammcoder 4 жыл бұрын
If you solve it thn plz let me know also.
@ranjithak4325
@ranjithak4325 5 жыл бұрын
Hello Mr.Corey, I really like all your videos, i have a request if you can do a tutorial for reactJS and django application that would be really helpful. Best Regards, R
@dpapa2175
@dpapa2175 4 жыл бұрын
Is to late to ask for additional suggestions about resizing the image? I like what you have, it works, but would be cool to see your other research, too.
@tomwojcik
@tomwojcik 6 жыл бұрын
19:35 imo you should pass *args **kwargs to both `save` methods. Also, I'm not sure Image closes automatically. I'd use `with open` on that `self.image.path`.
@mykoolspam
@mykoolspam 3 жыл бұрын
Question for around 3:00-4:00 minute mark: Why does UserRegisterForm and the UserUpdateForm have the attribute "email", but not "Username"? My understanding is that you only need to define the attributes that do not currently exist in the User Model; however, it looks like both Email and Username are already defined in the model. So why do we need the email attribute at all?
@dhanyadave6146
@dhanyadave6146 Жыл бұрын
Hi Corey, thank you for sharing your knowledge with us. I had a question, can we add an image field to the UserRegisterForm and then ask the user to provide an image when they register?
@deliciafernandes9946
@deliciafernandes9946 4 жыл бұрын
Start from 8:40
@egemenguney1715
@egemenguney1715 4 жыл бұрын
i've laughed like for 3 - 4 mins for this cute dogo hahahah :)
@jakubcharkiewicz5112
@jakubcharkiewicz5112 3 күн бұрын
Does any1 have a problem with forms? I cannot see the forms under the profile info although I fallowed Mr Schafer's steps
@DrArleth
@DrArleth 5 жыл бұрын
Hi Corey - I was wondering at 13:22 we have added both the u_form.save() and the p_form.save() - however, we have also added a signal that is supposed to save a profile each time the user is saved... so my question is - is it really necessary to also call save on the Profile form here?
@cfhsdowellm
@cfhsdowellm 5 жыл бұрын
I updated my profile picture after removing p_form.save() and found that it updated without issues.
@yashwanth_ravula1
@yashwanth_ravula1 5 жыл бұрын
In the previous videos, we ran migrations after making changes to models.py file. Here @22:10, how is it still working fine without running migrations?
@main_py5853
@main_py5853 5 жыл бұрын
Bro, he didn't add any new model fields in this video, he override the save method from the parent class!
@22vipul
@22vipul 6 жыл бұрын
i have an issue which i am unable to locate. i am unable to see the profile update form on the profile page. sm1 pls help.
@daksh_sagar
@daksh_sagar 6 жыл бұрын
Are you sure you are passing instances of UseUpdateForm and ProfileUpdateForm to the render method ?
@22vipul
@22vipul 6 жыл бұрын
@@daksh_sagar thanks for the help daksh bhai. i was not passing the context to the render function. now it works superfine.
@avvvqvvv99
@avvvqvvv99 6 жыл бұрын
you're both fucking legends everyone else with this problem: don't forget to add the context variable in views.py
@thomasandreasparpoulas9544
@thomasandreasparpoulas9544 6 жыл бұрын
Avvv Qvvv you are actually the one that pointed the spot, I was too burned to find the 'render method'... views.py and inside return render, with a coma after 'users/profile.html', add "context" (without quotes)
@avvvqvvv99
@avvvqvvv99 6 жыл бұрын
that's cool i was only able to fix my problem by reading what the above dudes said
@humanOSx
@humanOSx 6 жыл бұрын
It will be great if you can make a little tutorial show us how to delete old images while saving new in the profile section. Thanks for your awesome work man.
@abdelazizabdelioua890
@abdelazizabdelioua890 6 жыл бұрын
# Delete Previous Image To Avoid Duplicated Images Of Same User. previous_image = os.path.join(settings.MEDIA_ROOT, request.user.profile.image.name) os.remove(previous_image) I did it you can add this code after checking request method before saving new profile
@humanOSx
@humanOSx 6 жыл бұрын
@@abdelazizabdelioua890 Thanks.
@apoggione8
@apoggione8 4 жыл бұрын
Thanks for the video Corey. It appears the UserUpdateForm doesn't provide any feedback when a user tries to update their username/email to one that's already in use. How would you go about handling that? I'm sure it's possible with with a little documentation digging. But if anybody has a quick solution, I'd love to hear it.
@codinger4182
@codinger4182 4 жыл бұрын
While resizing the image, does it maintain the image or squishes to match the dimensions?
I'VE MADE A CUTE FLYING LOLLIPOP FOR MY KID #SHORTS
0:48
A Plus School
Рет қаралды 20 МЛН
Жездуха 42-серия
29:26
Million Show
Рет қаралды 2,6 МЛН
Their Boat Engine Fell Off
0:13
Newsflare
Рет қаралды 15 МЛН
5 Python Libraries You Should Know in 2025!
22:30
Keith Galli
Рет қаралды 87 М.
Coding a Web Server in 25 Lines - Computerphile
17:49
Computerphile
Рет қаралды 359 М.
Django Signals - Introduction!
18:20
BugBytes
Рет қаралды 3,7 М.
5 Good Python Habits
17:35
Indently
Рет қаралды 696 М.
Python AI Web Scraper Tutorial - Use AI To Scrape ANYTHING
45:36
Tech With Tim
Рет қаралды 228 М.
5 Useful F-String Tricks In Python
10:02
Indently
Рет қаралды 342 М.