Python Django Tutorial: Full-Featured Web App Part 8 - User Profile and Picture

  Рет қаралды 432,846

Corey Schafer

Corey Schafer

Күн бұрын

Пікірлер: 1 100
@HarmenHoek
@HarmenHoek 4 жыл бұрын
Quick heads up for 14:00. os is not imported by default in my case, as BASE_DIR uses pathlib instead of os. Add the extra line manually: import os
@abeflor8830
@abeflor8830 4 жыл бұрын
MEDIA_ROOT = Path(BASE_DIR, 'media') thanks man
@wabschall
@wabschall 3 жыл бұрын
@@abeflor8830 You can also just use slashes. MEDIA_ROOT = BASE_ROOT / 'media' docs.python.org/3/library/pathlib.html#operators
@prasangsinghal7887
@prasangsinghal7887 3 жыл бұрын
Django switched to Pathlib from version 3.
@Ionannes
@Ionannes 3 жыл бұрын
Thanks.
@Amanda-qu9uw
@Amanda-qu9uw 3 жыл бұрын
@@abeflor8830 Thanks guys!!
@congcuongnguyen413
@congcuongnguyen413 2 жыл бұрын
0:22 - profile model, one to one relationship 3:06 - image field 3:47 - __str__ method 4:56 - migration 5:44 - install Pillow 6:36 - add profile to admin page 9:06 - interact with profile on shell 12:41 - setting media root, media url 18:22 - profile template 20:57 - add media route into project url pattern 24:38 - upload default.jpg 26:20 - django signals 32:10 - import signals into ready function of apps.py
@mishterpreshident
@mishterpreshident 5 жыл бұрын
I have a long-term university-paid subscription to Lynda and have spent many, many hours there learning code. It's a great service, and I love it, BUT THIS VIDEO SERIES IS BETTER than any series on Django I've found there!!!! You have filled in a number of "blanks" left by other tutorials and I feel much more confident that I actually understand the framework now.
@Digital963
@Digital963 5 жыл бұрын
I have had the same experience and feel exactly the same about the paid Udemy courses on Django. We are blessed to have this CH.
@christianramirez8905
@christianramirez8905 6 жыл бұрын
You are legitimately the best teacher I've seen on KZbin. With other tutorials here on KZbin I follow along but feel like I don't actually learn much. But with your explanations it's easy for me to follow along and apply the knowledge into my own projects!
@Digital963
@Digital963 5 жыл бұрын
I feel the same, we are blessed to have this Ch.
@hafiz123875
@hafiz123875 5 жыл бұрын
AYYYEEEE MY GOOD SIR
@cs_patterson
@cs_patterson 5 жыл бұрын
I'm a student in Ghana(West Africa). I don't have the means to contribute to the patreon....but surely, I'm going to make so many others wanting to learn python and Django/flask hear of you. I'm so grateful for the impact you're having on me.
@coreyms
@coreyms 5 жыл бұрын
Thanks!
@SiphoMkhwanazi
@SiphoMkhwanazi 5 жыл бұрын
At first I thought Django was a bit complicated.. Corey made it seem easy and my confidence has grown.
@reenadangi1498
@reenadangi1498 5 жыл бұрын
You are the best ! I am in a coding boot camp and I feel your videos are much better than boot camp! Will pass on money as soon as I start making some !
@mikkeljrgensen3850
@mikkeljrgensen3850 6 жыл бұрын
I've been looking for a sensible explanation for this bit for roughly 4 months now, and I just wanted to express my absolute awe. Absolutely professional, handy with the ol' typewriter, no rubbish code and moreover no rubbish small talk. You sir, are a God among ants within the django tutorials realm, hands down. An instant subscription was made, obviously. Thank you ever so much for taking the time to make these videos ^_^
@crimcrow
@crimcrow 6 жыл бұрын
I just sent 15€ from paypal for your amazing job. I did few tutorials and yours is so clear. Thanks again :)
@coreyms
@coreyms 6 жыл бұрын
Thanks!
@bartox-tt4pg
@bartox-tt4pg 5 жыл бұрын
@@coreyms Can you give us auto subtitles pls. It help me a lot :(
@akashgkrishnan9596
@akashgkrishnan9596 4 жыл бұрын
This tutorial is the best tutorial i hve seen so far. its the best. paid contents dont even have the explanations. I will donate when i land my first job as a django dev. thanks a ton corey
@coreyms
@coreyms 4 жыл бұрын
Thanks!
@anujkondhalkar9776
@anujkondhalkar9776 4 жыл бұрын
Yes. Me too.
@Eddyyc
@Eddyyc 5 жыл бұрын
i found that putting the picture of who displayed the comment looks much nicer, so in the home.html right above the post.author if we add the line the post section looks a bit nicer, i am new at this but thanks to Corey i was able to understand some concepts.
@oussamafqihberrada5111
@oussamafqihberrada5111 3 жыл бұрын
That's a very nice touch, thanks
@jaycel779
@jaycel779 6 жыл бұрын
Firstly, Great tutorial Corey! Simply the best! For those of you having issues where the profile isn't saving or the default image isn't showing up, please make sure to tab properly. In the apps.py file in the users directory, please make sure that 'def ready(self):...' isn't on the same column as 'class UserConfig(AppConfig). Tab appropriately. Hopefully, this helps someone. God Bless!
@ginisksam
@ginisksam 4 жыл бұрын
Am still having problem of not getting the default images showing after following your suggestion. Will move on to next Part 9. Cant wait to continue.
@SaudMukhair
@SaudMukhair 9 ай бұрын
@@ginisksam hey i am getting the same issue here ? can u help me with this ?
@sc1ph3r34
@sc1ph3r34 3 жыл бұрын
For those not getting a profile pic to load around the 25:30 mark, make sure you're putting the default.jpg into the project_name/media folder, and not in the project-name/media/profile_pics folder. I didn't listen to Corey closely enough, but he mentions this specifically, although it seems minorly counterintuitive.
@snerd6936
@snerd6936 3 жыл бұрын
I NEEDED THIS. Thank you for pointing this out.
@Will_CS
@Will_CS 2 жыл бұрын
none of the images are loading, can't figure out why. do you got this issues too? note: the files are at the correct directories
@homosociologicus2000
@homosociologicus2000 2 жыл бұрын
@@Will_CS Had the same problem. Along with urlpatterns += static(settings.STATIC_URL, document_root=settings.STATIC_ROOT) try adding to the root urls.py this urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
@josephinewai8770
@josephinewai8770 2 жыл бұрын
@@homosociologicus2000 Thank you for this, I followed this and got my profile pic loaded!
@Beaupa76
@Beaupa76 2 жыл бұрын
@@homosociologicus2000 thanks for taking the time. Helped me as well :)
@Andrey-ny2dv
@Andrey-ny2dv 9 ай бұрын
Man, I run into some issues like Pillow, and I am like "oh, man, I need to solve it because Corey has it installed". I solve it and then next frame you are showing what to do. Really appreciate your work.
@StevenTse
@StevenTse 5 жыл бұрын
thankyou Corey, great vid great work! btw, for those struggling on default picture, create a profile for your user (without adding picture), because you need to create profile for the user in order to add default picture to the profile.
@namesare4fools
@namesare4fools 5 жыл бұрын
THANK YOU !!!!.. i just gone mad searching for solution XD
@ramfattah275
@ramfattah275 5 жыл бұрын
Thank you !!
@motlatsimoea
@motlatsimoea 4 жыл бұрын
Thank you for this! was getting frustrated
@djsmanoj0000
@djsmanoj0000 4 жыл бұрын
Sorry im going mad for the solution can you explain it briefly? Please @motlasti
@motlatsimoea
@motlatsimoea 4 жыл бұрын
@monoj sorry for the late reply. African timezone. My understanding is that that users you created before you created the Profile model do not get a profile, which also means they don't get an image field. Only those users you create after creating the Post model will have the image field apply to them. Furthermore, take care to store that default picture in the right place. I made a mistake there as well. I hope this helps.
@ABASSANIMERIKUKU
@ABASSANIMERIKUKU 2 ай бұрын
I think up to this far, my love for Django is as strong as the tutor....such amazing work. God bless you.
@dagmawigutu243
@dagmawigutu243 4 жыл бұрын
Hands down the best teacher I've ever seen! , i wish we had more like you. Thank you for generously sharing you're knowledge 👏👏
@JavedAli-fu4kk
@JavedAli-fu4kk 4 жыл бұрын
you are the best teacher in the world. I have seen many videos and I have learned many things from you. 3:08 we have to specified the related_name='profile'. so the reverse accessor will be called profile not userprofile.
@remixowlz
@remixowlz 4 жыл бұрын
You're really amazing! Even after 1 year and I came back again to relearn and I am able to absorb everything smoothly from you! Thank you Corey!
@entertechinc
@entertechinc 5 жыл бұрын
Excellent Teacher! You make me to love the Django framework more and more! Keep the awesome work Corey. Simple I have to say thank you so much!!!!!!!!!!
@carlfranz6805
@carlfranz6805 2 жыл бұрын
re: signals (31:10)... Corey: "I hope that makes sense..." Me: "Not even a little." 🤣
@paridhigupta2747
@paridhigupta2747 2 жыл бұрын
I couldn't have learnt Django without these series. You're a magician Corey.
@nicachipal1
@nicachipal1 6 жыл бұрын
Man, I love your videos. You are one a few BEST Teachers on this planet.
@moe3551
@moe3551 Жыл бұрын
Big ups for Corey! He's the best. Thanks alot for this tutorial, even after years of django experience, I'm still coming back to this tutorial!
@lardosian
@lardosian 5 жыл бұрын
For those having problems with creating a user profile Corey has pinned the solution in the next video.
@o1-preview
@o1-preview 5 жыл бұрын
Thanks for the head up²
@منبرالعلوم
@منبرالعلوم 4 жыл бұрын
There is nothing in the next vedeo
@alimamdouh493
@alimamdouh493 3 жыл бұрын
@@منبرالعلوم You need to add your app under installed apps as ''appname.apps.AppnameConfig' if your profile isn't being autocreated!
@piacademy1991
@piacademy1991 3 жыл бұрын
@@alimamdouh493 thanks a lot.
@landolabrum
@landolabrum 3 жыл бұрын
DEFINATELY THE BEST DJANGO TUT I've seen! thanks!
@deepakpatidar8462
@deepakpatidar8462 4 жыл бұрын
For anyone using Path from pathlib library, and getting an error saying 'os' not defined, please replace the following line from the video: Replace: MEDIA_ROOT = os.path.join(BASE_DIR, 'media') With: MEDIA_ROOT = BASE_DIR.joinpath('media') Also, if it still throws error, please check that you have the following line in your settings.py: BASE_DIR = Path(__file__).resolve().parent.parent If its not there, please add it right after the Path import (where you should find it if it is there) Great tutorials Corey :)
@fabrzy3784
@fabrzy3784 4 жыл бұрын
dont you just have to do "import os" in the settings file ?
@deepakpatidar8462
@deepakpatidar8462 4 жыл бұрын
@@fabrzy3784 no.. since we are not using the os library, we are using the Path library which should be imported beforehand ^^
@fabrzy3784
@fabrzy3784 4 жыл бұрын
@@deepakpatidar8462 but if the error is saying "os not defined" i fixed it with just importing os
@fabrzy3784
@fabrzy3784 4 жыл бұрын
@@deepakpatidar8462 also you are using the os library
@deepakpatidar8462
@deepakpatidar8462 4 жыл бұрын
@@fabrzy3784 yes, you can import os library and use the exact same code that is shown in the video.. I'm not using os library, and my comment focuses primarily on using Path library instead of os library.. since when I created a django project recently, os library was not imported by default in my settings.py file..
@kylefleming9556
@kylefleming9556 3 жыл бұрын
Love the comments, I reference this tutorial at least once a year as a refresher... Thanks for your kind work!
@ralphcaritativo2033
@ralphcaritativo2033 5 жыл бұрын
DONE TUTORIAL #8! Thank you SENPAI! :) BTW im from Philippines 😁
@johnlemontv7590
@johnlemontv7590 4 жыл бұрын
I`m fresh Grad and sure this one of the best series so far to start. Thanks a lot bro
@SIDDHANTKUMARSingh10on10
@SIDDHANTKUMARSingh10on10 5 жыл бұрын
I loved going through your tutorials.
@Digital963
@Digital963 5 жыл бұрын
Cory, I truly cannot thank you enough for your content! Please also consider doing some Q&A as a live stream, that would be great! Thanks again!!!
@Kornchipzzz
@Kornchipzzz 4 жыл бұрын
If you get the UserDoesNotExist error, PLEASE double check your function name. I forgot to rename it and I had 2 create_profile functions. 20 mins of debugging later I found it :)
@firstofherkind4136
@firstofherkind4136 3 жыл бұрын
Having this issue. Still haven’t been able to fix the problem.
@shubhamsirothiya2551
@shubhamsirothiya2551 3 жыл бұрын
@@firstofherkind4136 I am also getting this error ModuleNotFoundError: No module named 'users.signals' can u help me?
@skarverse
@skarverse 4 жыл бұрын
tnx to your videos ,those were my first step in django , i am glad that i found your playlist first.....i came now to refer about image field again😁 31:26 i found that we can use PROFILE_OBJECT,CREATED=profile.objects.get_or_create(user=request.user) in views.py we can pass it as instance to form or work it out based on requirement i thought it might help someone i found this after searching for three days
@brownbread2916
@brownbread2916 4 жыл бұрын
Should incase you have errors implementing the signals, you can do this to your users models.py file def save(self, *args, **kwargs): super(Profile, self).save(*args, **kwargs)
@gauravabhishek3930
@gauravabhishek3930 4 жыл бұрын
thanks brother. it worked
@brownbread2916
@brownbread2916 4 жыл бұрын
@@gauravabhishek3930 glad it did mate
@arunaiarun1409
@arunaiarun1409 4 жыл бұрын
@@brownbread2916 In user model.py we have only Profile model.. are you saying to override profile model save() method
@paulrodriguez5058
@paulrodriguez5058 4 жыл бұрын
absolute life savor thanks g
@liorbm1
@liorbm1 4 жыл бұрын
Thanks!!
@akashdipbaral254
@akashdipbaral254 5 ай бұрын
24:20 If anyone having trouble with the profile image covering a large part of the screen or the entire screen, you can edit the template 'profile.html' to specify the height and width of the profile image like the following line:
@akinsolasalem3715
@akinsolasalem3715 Ай бұрын
profile image not loading at all. i will appreciate if you can help me with that
@ErzaKaneki
@ErzaKaneki Ай бұрын
Tyvm for this tip!!! Helped me understand how to modify the image! Props!!
@william.darrigo
@william.darrigo 4 жыл бұрын
Just want to give a shoutout to someone very important in my life who inspired me to pursue programming....... TESTUSER you the man
@zacksims3623
@zacksims3623 3 жыл бұрын
Definitely the most dense tut in this series. Might need to watch this one twice, but it was well layed out. Thanks!
@fantomgamer9684
@fantomgamer9684 2 жыл бұрын
If you are having problems with the default image. Ensure you rename whatever picture you're using to default and place that image in the media folder not the profile pics sub folder in the media folder
@investmentapps7826
@investmentapps7826 5 жыл бұрын
On my next paycheck, I will contribute to you, I am really enjoying your tutorials. Just for information to other viewers, if you have left the server running whilst saving the models.py file it will tell you (HINT) that you need get Pillow. It also shows other useful typo errors. I also understood the importance of reading the documentation and testing out things.
@coreyms
@coreyms 5 жыл бұрын
Thanks!
@RahulKumar-tg5zb
@RahulKumar-tg5zb 4 жыл бұрын
For those that the profile wasn't created automatically, you must put it [default_app_config = 'users.apps.UsersConfig'] in your users/__init__.py and also check that default.jpg should not inside media directory . But both media and defalt jpg should be in same place.
@Elmonolitvideos
@Elmonolitvideos 4 жыл бұрын
Thanks!!!
@gee_rex
@gee_rex 3 жыл бұрын
thanks Rahul, i was actually stuck there
@gee_rex
@gee_rex 3 жыл бұрын
but am now stuck here - ImportError: cannot import name 'Profile' from 'post2.models' i named my app 'post2' this happened while trying to create ProfileUpdateForm
@Zenithh
@Zenithh 5 жыл бұрын
If a profile doesn't get created when you sign up a new user, add: default_app_config = 'users.apps.UsersConfig' to the __init__.py file in the users app. This solved my issue, even when the code was correct and I followed the steps in this video properly.
@sitaramchikkala
@sitaramchikkala 5 жыл бұрын
@ProducedByZenith This didn't solve my issue, what else can be done ??
@Zenithh
@Zenithh 5 жыл бұрын
@@sitaramchikkala Not sure mate, just search online with your issue and see what the internet says on how to fix it.
@jnyfah
@jnyfah 5 жыл бұрын
@sitaram chikkala have you gotten a solution ?
@umdmrlbro
@umdmrlbro 4 жыл бұрын
at 32:15, why do we do instance.profile.save() ? Where is 'profile' with lowercase 'p' defined?
@huboy2004
@huboy2004 4 жыл бұрын
Did you find out why ??
@erickssonnastor5359
@erickssonnastor5359 4 жыл бұрын
i feel like it has something to do with "users/views.py" where @login_required is needed for save_profile func to work. Not really sure if this is right tho but let me know if you find out the exact reason
@umdmrlbro
@umdmrlbro 4 жыл бұрын
This seems to be a Django convention to do with OnetoOne model relationships. In this case, we have a 'Profile' class in our models.py with a OnetoOne relationship to user defined as: user = OnetoOne(User, ...). I don't know the correct terminology here but this is my understanding of it: when we have a view (or in this case a signals.py) where we have direct access to a 'Profile' instance, we can get it's user by doing instance.user.whatever_attribute However, when we try to do this in the opposite direction (i.e. we have access to a 'User' instance and we want the users 'Profile') we do instance.profile.whatever_attribute with the lowercase 'p' in question. When you define a OnetoOne (or any model relationship like FK) relationship, it is obviously only defined within one of the models. In this case, we explicitly define the relationship within the 'Profile' model. I think when we do this, Django does some magic under the hood where it creates the relationship in the opposite direction, i.e. it does the equivalent of profile = OnetoOne (Profile, ...) within the 'User' model. When it does this, it seems to simply take the lowercase of the name of the related model, in this case 'Profile'. Not a satisfactory answer, I know, but Django seems to do a lot of things like this. Another example is when you create a new app in your project. The app config name that you include in your project settings.py is automatically generated by Django in the apps.py, so for an app named 'profile', Django will generate a 'ProfileConfig' class in the app's apps.py file. EDIT: The answer is here docs.djangoproject.com/en/3.0/topics/db/queries/#additional-methods-to-handle-related-objects "If a model has a ForeignKey, instances of the foreign-key model will have access to a Manager that returns all instances of the first model. By default, this Manager is named FOO_set, where FOO is the source model name, lowercased. This Manager returns QuerySets, which can be filtered and manipulated as described in the “Retrieving objects” section above."
@umdmrlbro
@umdmrlbro 4 жыл бұрын
​@@huboy2004 I have found the answer here: docs.djangoproject.com/en/3.0/topics/db/queries/#additional-methods-to-handle-related-objects "If a model has a ForeignKey, instances of the foreign-key model will have access to a Manager that returns all instances of the first model. By default, this Manager is named FOO_set, where FOO is the source model name, lowercased. This Manager returns QuerySets, which can be filtered and manipulated as described in the “Retrieving objects” section above."
@umdmrlbro
@umdmrlbro 4 жыл бұрын
​@@erickssonnastor5359 I have found the answer here: docs.djangoproject.com/en/3.0/topics/db/queries/#additional-methods-to-handle-related-objects "If a model has a ForeignKey, instances of the foreign-key model will have access to a Manager that returns all instances of the first model. By default, this Manager is named FOO_set, where FOO is the source model name, lowercased. This Manager returns QuerySets, which can be filtered and manipulated as described in the “Retrieving objects” section above."
@laurafernandez4744
@laurafernandez4744 2 жыл бұрын
I've been watching several videos until I came across this one, and it really helped me a lot! thanks!!
@user-yj7rc2qs8d
@user-yj7rc2qs8d 4 жыл бұрын
If you are having this error "Instance of 'OneToOneField' has no 'username' member" in users/models at 'return f'{self.user.username} Profile," here is the solution: 1. pip install pylint-django 2. If you are using vscode, go your .vscode/settings.json and add this snipet with the "python.pythonPath" existing there, separate them with comma: "python.linting.pylintArgs": [ "--load-plugins", "pylint_django" ] -> Or, if you have a .pylintrc file, you can add this line to load the plugin: [MASTER] load-plugins=pylint_django Then you are good to go
@kshitijchourey441
@kshitijchourey441 4 жыл бұрын
Hey, First of all thanks for addressing this issue. I'm working with vscode and having trouble with this, could you please elaborate on this a little more? I found the python path in settings but the field simply says python, That's it. Should I copy this whole snippet there?
@user-yj7rc2qs8d
@user-yj7rc2qs8d 4 жыл бұрын
@@kshitijchourey441 Got to this link, I explain better there. If it works for u, support me there, by leaving a comment. And if you are still having a problem with it, let me know. stackoverflow.com/questions/55204906/instance-of-onetoonefield-has-no-username-member/62771766#62771766
@sarthakbhutani7413
@sarthakbhutani7413 4 жыл бұрын
is your profile page responsive for mobile screen??
@sarthakbhutani7413
@sarthakbhutani7413 4 жыл бұрын
@@user-yj7rc2qs8d is your profile page responsive for mobile screen??
@user-yj7rc2qs8d
@user-yj7rc2qs8d 4 жыл бұрын
@@sarthakbhutani7413 To make your app responsive, you can use Bootstrap class: instead of .
@paulohsgoes1959
@paulohsgoes1959 4 жыл бұрын
Man, you've been made the best Django tutorials ever. Congrats
@davicarvalho9419
@davicarvalho9419 4 жыл бұрын
I had a problem that the signal wasn't working after all of that (The profile wasn't being created). What solved to me was: 1 - Adding *post_save.connect(save_profile, sender=User)* at the end of *signals.py* 2 - Adding *default_app_config = 'users.apps.UsersConfig'* into __init__.py , that is on root directory of users's aplication
@haliax8013
@haliax8013 5 жыл бұрын
First of all, thank you so much for your open-source approach and also for making information accessible and free for all. To me, these virtues are very important and admirable. On the other hand, like Einstein said: "If you can't explain it simply, you don't understand it well enough." And as also like Da Vinci said: "Simplicity is the ultimate sophistication." So because of that, i firmly believe that the ultimate success in both education and teaching is to simply teach things like a 5 years old can understand. And i believe that this ability is a very rare and exceptional ability that only a few have. Based on the videos of you I watched, I can confidently claim that I have no doubt that you are especially blessed with this ability. Congrats! If we get to the main point, my current progress is halted because of missing of subtitles in your video. As i have hard of hearing and not being a native-speaker, i rely heavily on subtitles, i just can't understand without them. So can you please add auto-generated subtitles by KZbin to this video? Thanks in advance!
@jasoncalleja126
@jasoncalleja126 5 жыл бұрын
8:07 I tried to add profile, but I got an Operational error: no such column: users_profile.user_id. Please help.
@shaikirfanameer359
@shaikirfanameer359 5 жыл бұрын
same problem bro did u sort it out now?
@stevenpawlowski4873
@stevenpawlowski4873 5 жыл бұрын
@@shaikirfanameer359 Try running "python manage.py migrate --run-syncdb"
@shaikirfanameer359
@shaikirfanameer359 5 жыл бұрын
@@stevenpawlowski4873 I tried that too
@austincoldiron
@austincoldiron 4 жыл бұрын
It may be too late: But I just renamed the db.sqlite3 file, deleted the 0001 file in users app, then --> makemigrations --> migrate. You have to also createsuperuser again
@ahmedmani1051
@ahmedmani1051 4 жыл бұрын
thanks corey your making the world a better and smarter place with every tutorial
@ashishverma-mj1kl
@ashishverma-mj1kl 5 жыл бұрын
@32:07 why save_profile is required? doesn't line no 10 serves the purpose?
@williamxtc8054
@williamxtc8054 5 жыл бұрын
I also a little bit confused about that part. (That part seems to me should be put into the `else` part of the first function??)
@williamxtc8054
@williamxtc8054 5 жыл бұрын
Also, this post does not explain this part either :-)
@williamxtc8054
@williamxtc8054 5 жыл бұрын
simpleisbetterthancomplex.com/tutorial/2016/07/28/how-to-create-django-signals.html
@NaachoElegante
@NaachoElegante 5 жыл бұрын
if u won't save it, then it will just create the profile for once and next time when you will try to login again it won't exist anymore, that's why we need to save it at the back end. If there is still some confusion, then we should try out the code without defining save_profile function and see.
@NaachoElegante
@NaachoElegante 5 жыл бұрын
@@williamxtc8054 Regarding the ELSE suggestion, that won't make any sense because that would mean either create the profile or save it, do you think this is what we want when we login to any site :)
5 жыл бұрын
First, thank you for all your videos ! Now i have an observation: when you delete a profile or a user you don't delete the picture attached to it. So I made a signal for this: @receiver(post_delete, sender=Profile) def delete_profile(sender, instance, **kwargs): if instance.image != Profile.image.field.default: os.remove(instance.image.path) it works, but if you see something i should change, I will really appriciate your expertise :)
@stanislavzoldak2198
@stanislavzoldak2198 5 жыл бұрын
Your tutorials are damn amazing, I learned so much in such a short time. I have only one question - to avoid confusion wouldn't it be better to create a new User model that would inherit built-in User model? (if that is even compatible with built in auth system)
@gee_rex
@gee_rex 3 жыл бұрын
Corey thanks bro, ur definitely one of the best teachers on planet earth
@bforbelive
@bforbelive 4 жыл бұрын
in django new version we don't have OS package in settings.py so we need to add IMPORT OS at beginning of the settings.py file.. in corey's style SAVE THAT!!!!!!!
@hunterallen4521
@hunterallen4521 3 жыл бұрын
Thank baby jesus I found your comment!
@JJChameleon
@JJChameleon 3 жыл бұрын
Thanks! This should be pinned!
@MrDe0
@MrDe0 2 жыл бұрын
you dont really have to import the OS package, just use the joinpath like this => BASE_DIR.joinpath('media') 🙂
@johnfluke6842
@johnfluke6842 3 жыл бұрын
Sorry for the previous question. I discovered that my default image was actually named default.jpg.jpg which did not show up til I went to the command line. Once i renamed it, everything worked fine. Thanks again for these wonderful videos.
@karan5539
@karan5539 4 жыл бұрын
You do not need save_profile function in the signals.py as the function Profile.objects.create will automatically save the profile. Or am I missing something? Also, like every video of this guy if you have no other way to support.
@piecucci
@piecucci Жыл бұрын
Thank you, it helped to fix my error!
@patrickkelly3053
@patrickkelly3053 4 жыл бұрын
Fantastic. Ran into a little issue. Maybe you mentioned it an earlier video but to get this section to work you need to add default_app_config = 'users.apps.UsersConfig' to the users/__init__.py
@AnnoyingErrors41
@AnnoyingErrors41 5 жыл бұрын
You need to add your app under installed apps as ''appname.apps.AppnameConfig' if your profile isn't being autocreated!
@afekhaijoseph5678
@afekhaijoseph5678 4 жыл бұрын
Thanks alot for this
@hiit-n-lift
@hiit-n-lift 4 жыл бұрын
Thanks a bunch for this. Was having challenges with this
@danianiazi8229
@danianiazi8229 4 жыл бұрын
ModuleNotFoundError
@shaffics2671
@shaffics2671 4 жыл бұрын
I am coming back to learning Django for what is now the 3rd time, and I finally get it haha!! I actually started using your video's to learn Python back in 2018... and now I teach Software Development myself (not Django clearly haha!). Thank you for your content, it has gotten me over many a hurdle in the early days and this series has given me something cool to focus on during the xmas break! You really are an incredible teacher!
@yuriyarin4027
@yuriyarin4027 3 жыл бұрын
At 16:50, I got "NameError: name 'os' is not defined" solved it by adding the line "import os" at the top of the page
@krishnmani3630
@krishnmani3630 3 жыл бұрын
thanks it works for me :)
@arjunnair4748
@arjunnair4748 3 жыл бұрын
THANK YOU
@akshgpt7
@akshgpt7 4 жыл бұрын
The way you explained the signals part was just phenomenal! It was so clear and concise. Thank you so much for this series!
@sarthakbhutani7413
@sarthakbhutani7413 4 жыл бұрын
is your profile page responsive for mobile screen??
@sarthakbhutani7413
@sarthakbhutani7413 4 жыл бұрын
can you help please
@akirankumar1998
@akirankumar1998 6 жыл бұрын
THANK YOU SOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO MUCH MAN!
@ulandokturbekuulu7752
@ulandokturbekuulu7752 4 жыл бұрын
I love your django series and I am going to watch your other videos as well as soon as i finish. My personal advice for you is to promote your youtube channel on instagram if you want of course. Because people gotta see this masterpiece. Thanks a lot man!
@jianwang8273
@jianwang8273 4 жыл бұрын
In User class, we never define a class variable called "profile". How can we access user.profile? And why not the capital case user.Profile?
@mountaindiaryfilms620
@mountaindiaryfilms620 4 жыл бұрын
In models.py we defined one to one relationship of "user]" with User Class. and post that we defined function based views "profile " in views.py . which we are returning request to profile.html. and "user" is a keyword from django for logged in user. So we can access" profile" through user.profile.
@tommyeagen3763
@tommyeagen3763 4 жыл бұрын
it is related to user model by one to one relationship so we each user have 1 profile so django model offers us that power
@grzesupel
@grzesupel 5 жыл бұрын
One of the best tutorial and profile to learning python, very clearly explanation, thanks!
@mazeenmuhammed
@mazeenmuhammed 5 жыл бұрын
Even though I place the default picture in media folder , djaamgo isn't able to pic that up ..
@jjmovies867
@jjmovies867 5 жыл бұрын
name that image as default.jpg
@Dubyarex
@Dubyarex 5 жыл бұрын
Click the link on github to actually see the image then right click and save as. Should fix it
@idugi
@idugi 5 жыл бұрын
make sure it's not inside the profile pictures subfolder, just put it in the root folder
@Sirreal45
@Sirreal45 5 жыл бұрын
@@jjmovies867 or...change the name in models.py image = models.ImageField(default='default_user.jpg', upload_to='profile_pics') default=anythingyouwant.png, ...
@jjmovies867
@jjmovies867 5 жыл бұрын
@@Sirreal45 that's a good and better option to do as well
@monishpv8
@monishpv8 3 жыл бұрын
If anyone feels confused at 30:00 , you can use this: @receiver(post_save, sender=User) def create_profile(sender,instance,created,**kwargs): if created: created_profile=profile(user=instance) created_profile.save()
@nehat786
@nehat786 6 жыл бұрын
Dont know why i am getting this error in dev server Not Found: /media/profile_pics/Abdul_Rasid.jpeg [07/Sep/2018 17:54:17] "GET /media/profile_pics/Abdul_Rasid.jpeg HTTP/1.1" 404 3006 and image is also not showing in profile page
@niteshrawat576
@niteshrawat576 6 жыл бұрын
Same problem , help Corey! :P Not Found: /media/profile_pics/my_pic.jpg [16/Sep/2018 16:01:00] "GET /media/profile_pics/my_pic.jpg HTTP/1.1" 404 2759
@niteshrawat576
@niteshrawat576 6 жыл бұрын
Hi Nehat, Try to check the static url_pattern you have added, make sure it is using MEDIA_URL and MEDIA_ROOT instead of STATIC. Thanks
@LieviSilva
@LieviSilva 6 жыл бұрын
Hey, i had the same error. The problem is that i put the settings.DEBUG on the wrong url file. This setting is on the project url file, not on the application url
@bektursunsamatuulu9772
@bektursunsamatuulu9772 6 жыл бұрын
@@LieviSilva Rename your image as "default.jpg"
@sugiyamakei3553
@sugiyamakei3553 6 жыл бұрын
@@niteshrawat576 This solved my problem. Thanks!
@joanbo2346
@joanbo2346 4 жыл бұрын
The signals setup works perfect, even with Django's version 3.0.7. Really thanks Master Teacher
@sarthakbhutani7413
@sarthakbhutani7413 4 жыл бұрын
is your profile page responsive for mobile screen??
@sarthakbhutani7413
@sarthakbhutani7413 4 жыл бұрын
can you help me please??
@Rajshah908
@Rajshah908 5 жыл бұрын
Thank You for helping me, I have one problem when I make new register NewUser3 and after that, I just login in NewUser3 goto profile page I can not view profile default image, I just try your GitHub code, but the same problem is there can you help me
@Yunghamz
@Yunghamz 5 жыл бұрын
I have this problem too, did you find a solution?
@ishanpadalkar9072
@ishanpadalkar9072 5 жыл бұрын
Open the admin page and check if a profile is created for that user or not. If a profile doesn't exist, then the default image will not load!
@gunjanmistry91
@gunjanmistry91 4 жыл бұрын
thanks man
@ishanpadalkar9072
@ishanpadalkar9072 4 жыл бұрын
@Evgenii Kosharnyi True Story No worries ✌🏼
@Vuces
@Vuces 4 жыл бұрын
@@ishanpadalkar9072 oh my god i spent an hour or so lol thank you!
@ab5848
@ab5848 4 жыл бұрын
You're just fantabulous 🙏🙏. Words fall small to describe your greatness sir🙏
@bimosyahsiraj219
@bimosyahsiraj219 4 жыл бұрын
I got problem at this tutorial. Django said "django.db.utils.OperationalError: no such column: users_profile.user_id". I already checked my code and compared with your code at github and then I found no mistakes. Can you help me to fix it? Your answer will be useful sir. Thankyou
@bimosyahsiraj219
@bimosyahsiraj219 4 жыл бұрын
@Indu Ji okay,thank your for the advice. Have a good day!
@sarthakbhutani7413
@sarthakbhutani7413 4 жыл бұрын
Indu Ji hey can you help me please??
@banjialo
@banjialo 2 жыл бұрын
Great work mate! Enjoyed every bit of the tutorials
@roderickdanzing1414
@roderickdanzing1414 4 жыл бұрын
my image wont load..is there any specific sizes or resolution of image?? tia!
@kvicar7419
@kvicar7419 4 жыл бұрын
I have the same problem
@kvicar7419
@kvicar7419 4 жыл бұрын
I found the solution. Change settings.ROOT_URL to settings.MEDIA_URL in urls.py file. It helped me, It was just a little silly mistake. Good luck
@konikarawat9653
@konikarawat9653 4 жыл бұрын
I have settings.MEDIA_URL only, but still my image is not loading.
@pradeepnaik1033
@pradeepnaik1033 4 жыл бұрын
Logout from your admin panel and then login with users credentials with frontend login page
@abutalib9293
@abutalib9293 4 жыл бұрын
Hey did anyone resolved that error im facing the same problem now
@slickwillie3376
@slickwillie3376 4 жыл бұрын
So far so good. Great video! Continuing onward...
@Skaxarrat
@Skaxarrat 6 жыл бұрын
Why do we create a Profile model instead of extending the actual User? There is any benefit on doing it this way?
@dodokwak
@dodokwak 6 жыл бұрын
As far as I understand we use built-in User Model to make a table in the db for users and separately table for objects of Profile. They are connected with OneToOne relationsips. At the end of the video we synchronize creation of a new user and his(her) profile. Benefit - more flexibility as procedure of creation (singing up) is separated from the creation of the profile.
@davidbrown2806
@davidbrown2806 6 жыл бұрын
With the Profile you are extending the User model. Otherwise you have to totally change the User model as a Custom Model.
@renitalobo927
@renitalobo927 6 жыл бұрын
Extending the existing User model¶ There are two ways to extend the default User model without substituting your own model. If the changes you need are purely behavioural and don’t require any change to what is stored in the database, you can create a proxy model based on User. This allows for any of the features offered by proxy models including default ordering, custom managers, or custom model methods. If you wish to store information related to User, you can use a OneToOneField to a model containing the fields for additional information. This one-to-one model is often called a profile model, as it might store non-auth related information about a site user. Ref: docs.djangoproject.com/en/2.1/topics/auth/customizing/
@HaileeMiu
@HaileeMiu 5 жыл бұрын
Hey Corey. Since you are using a mac, you can go to system preferences>accessibility>zoom and select "use scroll gesture" and it will allow you to zoom on any part of your screen" (aka the file structure in vs code)
@coreyms
@coreyms 5 жыл бұрын
Thanks! I might try that
@raphaelsantanaguitar
@raphaelsantanaguitar 6 жыл бұрын
Thank you very much for the class and the series. I have only one complaint: i think the videos are getting less and less conceptual. I see what you're doing, i can be convinced of why you're doing it but the knowledge about how the things work on the background don't scratch the surface. I'll do my homework and read more about those decorators you used, but i hope my input is well received.
@magikarpusedsplash8881
@magikarpusedsplash8881 5 жыл бұрын
He has already made a half hour tutorial on decorators (plus two others), so he does go over it, and at the beginning of the first video he states that he won't be going over basic stuff in detail (he isn't explaining if statements or how function definitions work), because he already has videos on that content and this series is about Django, specifically. tl;dr, if he covered every underlying topic (that he already has videos about) along the way then the series would be at least three times longer.
@kiranraj-dw5gq
@kiranraj-dw5gq 5 жыл бұрын
Amazing Tutorials.Thanks from India .You Rock!!
@AnilGupta-iv1rz
@AnilGupta-iv1rz 5 жыл бұрын
When i am creating the user and trying to logged in i am getting RelatedObjectDoesNotExist at /login/ can anyone explain why?
@saiday
@saiday 5 жыл бұрын
I don't know why, but on Django 2.2 only the last receiver receive the signal, you need to modify the codes to be like this: gist.github.com/saiday/f9e306b0ba5d73d7601ab8e4f3cc65ed
@akashgkrishnan9596
@akashgkrishnan9596 4 жыл бұрын
you are facing that issue cause the user you ave used for login does not have profile object present u can create a new user or update the user and create a profile object for the same user. guess you might have found this by the time i have commented. but anyways
@nz881
@nz881 4 жыл бұрын
@@saiday Thanks :)
@bojansimikic6350
@bojansimikic6350 3 жыл бұрын
​@@saiday thanks!!! This worked for me!!!
@sapnajain9166
@sapnajain9166 3 жыл бұрын
It was an amazing tutorial. Just want to suggest rather than righting the whole pile of code for just setting the default pic, you could have simply checked using this {% if user.profilepic.image %}
@al3ezi
@al3ezi 3 жыл бұрын
yes please where to add this ? my default pic not showing !!
@sapnajain9166
@sapnajain9166 3 жыл бұрын
​@@al3ezi Hi, Actually my code is a little different but can do this code above where you are showing your user actual Pic.Like- {% if not user.profilepic.image %}
@sapnajain9166
@sapnajain9166 3 жыл бұрын
And if you want to go by his method just add this line in your 'init.py' file of your app name. In this tutorial the app name was 'blog', so add this line in the init.py file of the blog app- default_app_config = 'blog.apps.blogConfig' .I think by mistake he forgot to tell
@avalancherr4792
@avalancherr4792 4 жыл бұрын
For those whom profile picture didn't load, name your default jpg image just default instead of default.jpg. Otherwise, the image name becomes default.jpg.jpg. Also make sure you are pasting the image in media folder and not profile_pic folder
@sarthakbhutani7413
@sarthakbhutani7413 4 жыл бұрын
can you help me please
@soumyazyx
@soumyazyx 5 жыл бұрын
Thank you Corey for your time and effort. Keep spreading the knowledge.
@goshmain982
@goshmain982 6 жыл бұрын
this part was kinda confusing for me :/ especially signals part. I find it difficult to use django docs. I hope I will get through this
@coreyms
@coreyms 6 жыл бұрын
Yes, the signals are a difficult concept to grasp. I am always needing to look at the documentation any time I do signals work as well, so you’re not alone
@direshkumarpradhan4376
@direshkumarpradhan4376 4 жыл бұрын
@@coreyms I wanted to ask that when save_profile method was created in that we write instance.profile.save() but what is 'profile' in this because the class inside the models.py was Profile and not profile so how does it work? Is there any inbuilt variable profile just like user?
@anonymousone6454
@anonymousone6454 3 жыл бұрын
@@direshkumarpradhan4376 did u find the solution...Me also having same issue
@sanneck
@sanneck 4 жыл бұрын
perfect content at the perfect speed with the perfect way to teach
@dotco22
@dotco22 6 жыл бұрын
Why there are no subtitles?
@shantanugupta1712
@shantanugupta1712 4 жыл бұрын
press c on ur system while watching video
@alizolfaghari3951
@alizolfaghari3951 11 ай бұрын
32:25 Why does this second signal is needed (lines 13, 14, 15)? I think it will save nothing and its redundant. am I right?
@alizolfaghari3951
@alizolfaghari3951 11 ай бұрын
I removed lines 13, 14, 15 and it worked well. What is the reason of using those lines?
@Crucizer
@Crucizer 5 жыл бұрын
The New THENEWBOSTON(bucky roberts)
@jasmintumulakestudillo5764
@jasmintumulakestudillo5764 5 жыл бұрын
Thank you very much for this video tutorial. It is straightforward and absolutely very professional.
@feysalibrahim9556
@feysalibrahim9556 5 жыл бұрын
I think those who disliked this video were Jamaicans because they read as dis i like
@jungiealbarico2724
@jungiealbarico2724 2 жыл бұрын
Warmest thanks for these quality videos Corey! 🙏
@panagiotisgoulas8539
@panagiotisgoulas8539 4 жыл бұрын
31:24 Since you instantiated a profile instance by Profile.objects.create(user=instance) and not by doing Profile(user=instance), the save_profile is not required.
@ahmad-ali14
@ahmad-ali14 6 жыл бұрын
this is the best toturial i ve ever seen
@moebazzi8412
@moebazzi8412 6 жыл бұрын
AMAZING AND CLEAR TUTORIALS WELL DONE COREY!!!
@sasanghaffari9424
@sasanghaffari9424 4 жыл бұрын
thank you very much for the great content! you make everything look cristal clear for me as someone who is trying to learn as a beginner!
@godsplace6602
@godsplace6602 6 ай бұрын
I am not able to login to my django administration page after the signal functionality, did anyone encounter it ?
@Yash42189
@Yash42189 2 жыл бұрын
Lol still the best after so many years and so many flashy videos from other channels.
@vegadevelopers
@vegadevelopers 9 ай бұрын
Amazing content and tutorial very detailed explanations! Thumbs Up.
@erwinnovo3014
@erwinnovo3014 Ай бұрын
You are great teacher! Kudos!
Support each other🤝
00:31
ISSEI / いっせい
Рет қаралды 81 МЛН
The evil clown plays a prank on the angel
00:39
超人夫妇
Рет қаралды 53 МЛН
Quando eu quero Sushi (sem desperdiçar) 🍣
00:26
Los Wagners
Рет қаралды 15 МЛН
Building reactive and modern components in Django with Unicorn
16:53
Cloud With Django
Рет қаралды 1,4 М.
Build a Python Website in 15 Minutes With Streamlit
18:37
Tech With Tim
Рет қаралды 88 М.
Python Django User Registration - Full Tutorial
17:41
Dave Gray
Рет қаралды 14 М.
Python Logging: How to Write Logs Like a Pro!
11:02
ArjanCodes
Рет қаралды 185 М.
Learn the Basics of Django Signals
22:37
Matt Freire
Рет қаралды 50 М.
Support each other🤝
00:31
ISSEI / いっせい
Рет қаралды 81 МЛН