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

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

Комментарии • 1,1 тыс.

  • @HarmenHoek
    @HarmenHoek 4 года назад +192

    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 года назад +16

      MEDIA_ROOT = Path(BASE_DIR, 'media')
      thanks man

    • @wabschall
      @wabschall 3 года назад +10

      @@abeflor8830 You can also just use slashes.
      MEDIA_ROOT = BASE_ROOT / 'media'
      docs.python.org/3/library/pathlib.html#operators

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

      Django switched to Pathlib from version 3.

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

      Thanks.

    • @Amanda-qu9uw
      @Amanda-qu9uw 2 года назад +1

      @@abeflor8830 Thanks guys!!

  • @congcuongnguyen413
    @congcuongnguyen413 2 года назад +28

    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 лет назад +37

    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 лет назад +3

      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 лет назад +92

    You are legitimately the best teacher I've seen on RUclips. With other tutorials here on RUclips 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 4 года назад

      AYYYEEEE MY GOOD SIR

  • @cs_patterson
    @cs_patterson 5 лет назад +7

    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.

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

    At first I thought Django was a bit complicated.. Corey made it seem easy and my confidence has grown.

  • @Eddyyc
    @Eddyyc 5 лет назад +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.

  • @mikkeljrgensen3850
    @mikkeljrgensen3850 6 лет назад +21

    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 ^_^

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

    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 !

  • @akashgkrishnan9596
    @akashgkrishnan9596 4 года назад +9

    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

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

    I just sent 15€ from paypal for your amazing job. I did few tutorials and yours is so clear.
    Thanks again :)

    • @coreyms
      @coreyms  5 лет назад +10

      Thanks!

    • @bartox-tt4pg
      @bartox-tt4pg 5 лет назад +12

      @@coreyms Can you give us auto subtitles pls. It help me a lot :(

  • @sc1ph3r34
    @sc1ph3r34 3 года назад +13

    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 2 года назад +1

      I NEEDED THIS. Thank you for pointing this out.

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

      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 года назад +8

      @@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 года назад +2

      @@homosociologicus2000 Thank you for this, I followed this and got my profile pic loaded!

    • @Beaupa76
      @Beaupa76 2 года назад +2

      @@homosociologicus2000 thanks for taking the time. Helped me as well :)

  • @jaycel779
    @jaycel779 5 лет назад +5

    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 года назад +3

      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 8 месяцев назад

      @@ginisksam hey i am getting the same issue here ? can u help me with this ?

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

    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 лет назад +1

      @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 ?

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

    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 !!

    • @motlatsimoea5615
      @motlatsimoea5615 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

    • @motlatsimoea5615
      @motlatsimoea5615 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.

  • @Andrey-ny2dv
    @Andrey-ny2dv 7 месяцев назад

    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.

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

    Hands down the best teacher I've ever seen! , i wish we had more like you. Thank you for generously sharing you're knowledge 👏👏

  • @ABASSANIMERIKUKU
    @ABASSANIMERIKUKU 28 дней назад

    I think up to this far, my love for Django is as strong as the tutor....such amazing work. God bless you.

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

    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!

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

    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 года назад +2

      @@deepakpatidar8462 also you are using the os library

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

      @@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..

  • @entertechinc
    @entertechinc 4 года назад +12

    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!!!!!!!!!!

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

    DEFINATELY THE BEST DJANGO TUT I've seen! thanks!

  • @lardosian
    @lardosian 5 лет назад +10

    For those having problems with creating a user profile Corey has pinned the solution in the next video.

    • @o1-preview
      @o1-preview 5 лет назад +1

      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 года назад +1

      @@alimamdouh493 thanks a lot.

  • @JavedAli-fu4kk
    @JavedAli-fu4kk 4 года назад +1

    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.

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

    Man, I love your videos. You are one a few BEST Teachers on this planet.

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

    Love the comments, I reference this tutorial at least once a year as a refresher... Thanks for your kind work!

  • @brownbread2916
    @brownbread2916 4 года назад +7

    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 года назад +1

      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!!

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

    I couldn't have learnt Django without these series. You're a magician Corey.

  • @william.darrigo
    @william.darrigo 4 года назад +8

    Just want to give a shoutout to someone very important in my life who inspired me to pursue programming.......
    TESTUSER you the man

  • @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.

  • @fantomgamer9684
    @fantomgamer9684 2 года назад +3

    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

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

    thanks corey your making the world a better and smarter place with every tutorial

  • @RahulKumar-tg5zb
    @RahulKumar-tg5zb 4 года назад +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 3 года назад +1

      Thanks!!!

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

      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

  • @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!

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

    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 года назад +1

      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?

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

    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()

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

    I loved going through your tutorials.

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

    I`m fresh Grad and sure this one of the best series so far to start. Thanks a lot bro

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

    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)

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

    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!!!

  • @user-yj7rc2qs8d
    @user-yj7rc2qs8d 4 года назад +12

    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 года назад +1

      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 .

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

    Definitely the most dense tut in this series. Might need to watch this one twice, but it was well layed out. Thanks!

  • @carlfranz6805
    @carlfranz6805 2 года назад +3

    re: signals (31:10)...
    Corey: "I hope that makes sense..."
    Me: "Not even a little." 🤣

  •  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 :)

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

    DONE TUTORIAL #8! Thank you SENPAI! :)
    BTW im from Philippines 😁

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

    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

  • @davicarvalho9419
    @davicarvalho9419 4 года назад +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

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

    Corey thanks bro, ur definitely one of the best teachers on planet earth

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

    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!

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

    I've been watching several videos until I came across this one, and it really helped me a lot! thanks!!

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

    You need to add your app under installed apps as ''appname.apps.AppnameConfig' if your profile isn't being autocreated!

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

    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 RUclips to this video?
    Thanks in advance!

  • @raphaelsantanaguitar
    @raphaelsantanaguitar 5 лет назад +5

    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.

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

    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.

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

    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

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

    Man, you've been made the best Django tutorials ever. Congrats

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

    THANK YOU SOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO MUCH MAN!

  • @shaffics2671
    @shaffics2671 3 года назад +2

    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!

  • @bforbelive
    @bforbelive 3 года назад +9

    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 года назад +2

      Thank baby jesus I found your comment!

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

      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') 🙂

  • @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

  • @Crucizer
    @Crucizer 5 лет назад +15

    The New THENEWBOSTON(bucky roberts)

  • @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

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

    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 лет назад +4

      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 года назад +1

      @@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

  • @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!

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

    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

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

    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

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

    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 года назад +1

      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 года назад +1

      ​@@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."

  • @thivuxhale
    @thivuxhale 2 года назад +2

    Nice and neat video as always, Corey.
    I have a question: why wouldn't we add image profile as a new field to the User model that already exists, but instead create a whole new Profile model and then link to User in 1-1 relation? In other words, when do we know we should create a new entity in the database or just add new attribute to an existing entity?

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

    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

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

    One of the best tutorial and profile to learning python, very clearly explanation, thanks!

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

    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

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

      make sure it's not inside the profile pictures subfolder, just put it in the root folder

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

      @@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

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

    The signals setup works perfect, even with Django's version 3.0.7. Really thanks Master Teacher

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

    8:07 I tried to add profile, but I got an Operational error: no such column: users_profile.user_id. Please help.

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

      same problem bro did u sort it out now?

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

      @@shaikirfanameer359 Try running "python manage.py migrate --run-syncdb"

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

      @@stevenpawlowski4873 I tried that too

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

      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

  • @akashdipbaral254
    @akashdipbaral254 3 месяца назад +1

    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 5 часов назад

      profile image not loading at all. i will appreciate if you can help me with that

  • @ashishverma-mj1kl
    @ashishverma-mj1kl 5 лет назад +3

    @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 :)

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

    You're just fantabulous 🙏🙏. Words fall small to describe your greatness sir🙏

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

    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 лет назад +5

      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 лет назад +1

      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/

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

    Great work mate! Enjoyed every bit of the tutorials

  • @dotco22
    @dotco22 6 лет назад +12

    Why there are no subtitles?

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

    perfect content at the perfect speed with the perfect way to teach

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

    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 лет назад +1

      I have this problem too, did you find a solution?

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

      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 года назад +1

      thanks man

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

      @Evgenii Kosharnyi True Story No worries ✌🏼

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

      @@ishanpadalkar9072 oh my god i spent an hour or so lol thank you!

  • @kiranraj-dw5gq
    @kiranraj-dw5gq 5 лет назад +2

    Amazing Tutorials.Thanks from India .You Rock!!

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

    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 года назад +1

      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

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

    This is better than the course I took on udemy.

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

      this is awesome but if you're looking for another awesome one, I recommend thenewboston's django tutorials

  • @yuriyarin4027
    @yuriyarin4027 3 года назад +5

    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

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

    Thank you very much for this video tutorial. It is straightforward and absolutely very professional.

  • @AnilGupta-iv1rz
    @AnilGupta-iv1rz 5 лет назад +3

    When i am creating the user and trying to logged in i am getting RelatedObjectDoesNotExist at /login/ can anyone explain why?

    • @saiday
      @saiday 5 лет назад +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!!!

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

    thanks for the video Corey, i would happy if you check why the subtitle is not showing 10s after beginning

  • @feysalibrahim9556
    @feysalibrahim9556 5 лет назад +5

    I think those who disliked this video were Jamaicans because they read as dis i like

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

    Is there a specific reason why we don't implement the ProfilePicture directly in the UserCreationForm we created in ep. 6-User Registration?
    Thanks a lot for your videos I love this channel!

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

    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 лет назад +7

      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 5 лет назад

      @@LieviSilva Rename your image as "default.jpg"

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

      @@niteshrawat576 This solved my problem. Thanks!

  • @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!

  • @howards5205
    @howards5205 3 года назад +2

    Hi Corey. This is a great tutorial series. Thank you so much for sharing these with us. I have followed all your videos in the Flask series and they have helped me immensely.
    I was curious though. When you were creating a user profile (automatically after user registration), why did you opt to utilize Django's signals? Couldn't you have just created a profile instance in users/views.py file after form validation and save it? Is there a benefit to using signals?

    • @Nikhil-yi3qc
      @Nikhil-yi3qc 2 года назад

      Iam getting unique constaint failed error while using signal, can you explain how to create profile using the way you have mentioned?

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

    Hey Corey, I have been working on a small project, and it was developing smoothly until I got a road block which I think this video is the solution for. However, due to the workflow of my website, I am not able to implement exactly the way you are trying to route to the profile page. My workflow is as below
    1) user sign up and see a login screen
    2) user login and now he see a form, where he/she needs to fill in mandatory fields
    3) save and then either click on "profile" page to see the profile data, or "save" button will redirect to the profile page automatically.
    4) user logout and the next time he/she logs in should see the profile page directly, and not the form to fill in the extra data.
    However, after going through your video on "profile" page, I have put the profile in the navbar. So, now even if the user log in to see the form page, he/she still has the profile link to redirect to the profile page through navbar, which is fine. But in the video I didn't see that how you are fetching the data from the data base to show in the "profile" page. May be I didn't understand properly. Sorry if this is a dumb question. I am completely new to web development in general. If you can help me out with the changes in the GET method, I can share my project details to you in google drive, or anyway you want.
    I have been working on this for some time now, and this is a big road block for me. Please let me know.

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

      I have opened a query on stackoverflow, you could also reply there if you wish
      stackoverflow.com/questions/61545611/how-to-redirect-to-a-profile-page-and-see-the-data-of-the-logged-in-user-in-djan

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

    So far so good. Great video! Continuing onward...

  • @userrrrr-l1r
    @userrrrr-l1r 4 года назад

    thank you so much you are one of the best teachers I have ever seen

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

    Thank you Corey for your time and effort. Keep spreading the knowledge.

  • @ahmad-ali14
    @ahmad-ali14 5 лет назад +2

    this is the best toturial i ve ever seen

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

    The best instructor that ever seen

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

    AMAZING AND CLEAR TUTORIALS WELL DONE COREY!!!