How to Handle User Authentication in Django

แชร์
ฝัง
  • เผยแพร่เมื่อ 3 ม.ค. 2025

ความคิดเห็น • 78

  • @mattfreire
    @mattfreire  4 ปีที่แล้ว +4

    ***
    Please note this video is over two years old. I've left it up for those of you who might get value from it but be aware that packages update and things change. It could not work for you and that might just be because the tech has changed by now.
    We have a recently created (2020) course on our website that covers authentication in Django. It is a paid course but the value you get is much more than this old tutorial. If you're interested check out learn.justdjango.com
    Thanks for your understanding!
    ***

    • @patrickknows2296
      @patrickknows2296 3 ปีที่แล้ว

      @Kyree Enzo why? Your gf cheating on you?

  • @mr-engin3er
    @mr-engin3er 5 ปีที่แล้ว +11

    Can you make a tutorial for how to reset the the password if user forgot.( Email authentication, password reset link or otp verification to reset password.)

  • @mindpower421
    @mindpower421 5 ปีที่แล้ว +2

    thanks man i was searching for it from a long time and your video provided me with all necessary information

  • @elbekkhaitov683
    @elbekkhaitov683 5 ปีที่แล้ว +1

    Best explanation of authentication in Django! Thank you so much

  • @st33lx2
    @st33lx2 4 ปีที่แล้ว

    my english its not really good I´m from chile and i watching for this kind of tutorial for looong time , I love you

  • @outright99
    @outright99 4 ปีที่แล้ว

    Brilliant! Now with this base explanation I´ll investigate now how to use LDAP to achieve the same thing... There is so many tutorials on how to achieve it that I´m having a headache... =) Thanks again!

    • @mcaanuj
      @mcaanuj 4 ปีที่แล้ว

      Hi Cristian, was you able to get it working with LDAP or some other sso server. I also have the same requirement, and struggling to find some good document/video.

  • @ayodele_great
    @ayodele_great 5 ปีที่แล้ว +2

    Many thanks for the tutorial

  • @abdullahbukhari1469
    @abdullahbukhari1469 4 ปีที่แล้ว +1

    Great Vid! What theme are you using in VS_Code

  • @exg421
    @exg421 3 ปีที่แล้ว

    I just want to know how to save and access those items to database?
    Pls help

  • @thebaldguy458
    @thebaldguy458 2 ปีที่แล้ว

    can you also upload a video on how we can customize the login and registration pages?
    cus it kinda looks ugly

  • @sagarkc3662
    @sagarkc3662 4 ปีที่แล้ว +1

    What if I want to add an extra field say nickname in built in User model...how can I do this..plz help..I searched the whole internet and got nothing😢😢😣🙏😣😢😢

  • @satisha7280
    @satisha7280 6 ปีที่แล้ว +1

    Thank You, can you make video on django graphs by taking excel or csv files as input.

    • @mattfreire
      @mattfreire  6 ปีที่แล้ว

      That’s a cool idea 🙌

  • @khadimhusen
    @khadimhusen 5 ปีที่แล้ว

    Very good tutorial

  • @derekkroeker4582
    @derekkroeker4582 3 ปีที่แล้ว

    Email2 should be password2, Confirming the email is rare to find on an website, did you do this, because it was easier?

  • @sharanappabiradar4496
    @sharanappabiradar4496 4 ปีที่แล้ว

    Hi sir... urls.py error in this file sir path can't be corrected sir...

  • @xuezhang7865
    @xuezhang7865 5 ปีที่แล้ว

    Thank you for your sharing, I have learned a lot. But there is a little question about UserLoginForm. In my opinion, if we use authenticate, which default check username and password. When we get the right username but wrong password, the user will be none, so the process will not execute user.check_password(password).

  • @bernardoolisan1010
    @bernardoolisan1010 4 ปีที่แล้ว

    hello there, greate tutorial, but, how can I see if users are connected in django administration, when I see the in the staff they are not?

  • @s1ars
    @s1ars 5 ปีที่แล้ว +5

    Hello Sir, thank you for having this channel and enlightening all of us with your knowledge in django.
    I tried followed your video and tried using valid username and invalid password, expecting to check the password error. however each time only user validation error message was returned.
    i also tried to print the "user" variable after authenticate method is called and each time the user value is returned as "None". Could you please help in knowing the way to get the "wrong password" error message.
    user = authenticate(username=username, password=password)
    print(user)
    if not user:
    raise forms.ValidationError('User does not exist')
    if not user.check_password(password):
    raise forms.ValidationError('wrong password')

    • @TarkanAcan
      @TarkanAcan 5 ปีที่แล้ว +1

      Hello friend, it has been a while and you probably found out how to do it but let me warn you. You really DON'T want to give that kind of clues to people trying username-password combinations on your site. For a long time this practice has been dubbed BAD PRACTICE.

  • @potojumuralidhar9128
    @potojumuralidhar9128 4 ปีที่แล้ว

    Thankyou sir but I have small doubt in how we connect this to template html with out form option

  • @adnanalvi7406
    @adnanalvi7406 5 ปีที่แล้ว +1

    I have my own model named 'Registeredmodel' how can i use or where to pass this model for user login ?

  • @infinitx1330
    @infinitx1330 4 ปีที่แล้ว

    Is it possible to have multiple custom user authentication methods for different users within the same Django app. Like an email and password for one type of user and a pin only for another type of user

  • @luizcarlosarrudajunior3402
    @luizcarlosarrudajunior3402 4 ปีที่แล้ว

    At 19:48, how did you keep the anonymous window in front, while typing in the background window?

  • @khawajaosama
    @khawajaosama 5 ปีที่แล้ว +1

    why email2 field is not showing ?

  • @AMC-throwaway
    @AMC-throwaway 5 ปีที่แล้ว

    What about setting up django for consuming an api? like if you were trying to consume/querying facebook, instagram, or a twitter api, or any api for that matter?

  • @austinhallett2395
    @austinhallett2395 4 ปีที่แล้ว

    I have an issue.. I have gotten this to work perfectly (thank you) but now I am concerned because once the credentials are entered, I am never prompted to enter them again... I have even removed the passwords from my browser's cache. I need to require credentials EVERY TIME the page is visited, even if the device may be trusted. Is there a way to automatically logout as soon as the page is left?

  • @thebaldguy458
    @thebaldguy458 2 ปีที่แล้ว

    Thank you, the video was very helpful and it really helped me great video
    subscribing (like sticker)

  • @skynet1024
    @skynet1024 4 ปีที่แล้ว

    can you please make a simple chat application in django..?

  • @TOn-fx2gr
    @TOn-fx2gr 4 ปีที่แล้ว +1

    Hey , i have my own form created with html and styled it with css i just want to validate it do i have to use {{ form }} in the html ? ? Thank you

    • @JimitRupani
      @JimitRupani 4 ปีที่แล้ว

      i am also doing the same can you share the example if you have done it. can you share any Github link or something

  • @aidenpearce5724
    @aidenpearce5724 5 ปีที่แล้ว

    you are using modelform in userregisterform.
    but why did you call set_password method in views ?
    when save() method is called, it's already save the password right (without separately call set_password) ?

  • @B0rn2Clutch
    @B0rn2Clutch 5 ปีที่แล้ว

    how can we add sessions to this page please guide

  • @kedharchundu5182
    @kedharchundu5182 6 ปีที่แล้ว +1

    Thnqqqq so much sir

  • @ahmedabdelhak8477
    @ahmedabdelhak8477 6 ปีที่แล้ว +2

    thank you for this cours

  • @lamechdesai3414
    @lamechdesai3414 4 ปีที่แล้ว

    Thanks but it dint help if one wants to create the authentication in another app that is not account since you are using django decorators

  • @dodokwak
    @dodokwak 6 ปีที่แล้ว

    Thanks. Just one question: one of the reason why we would make a custom User model (AbstractBaseUser) is that we' d like to use USERNAME_FIELD = 'email ' instead of default USERNAME_FIELD = 'username '. Why is it so important? Why not just ask user to enter his(her) email in the username field and save it? I don't see any limitations not to do it (@ is allowed for the username field in a form).

    • @vedxgaming8216
      @vedxgaming8216 6 ปีที่แล้ว +1

      You can't use Email verification function, what if user passed wrong email, you will not be able to check that.

    • @sharanappabiradar4496
      @sharanappabiradar4496 4 ปีที่แล้ว

      Hi sir... urls.py error in this file sir path can't be corrected sir...

  • @PythonAssister
    @PythonAssister 5 ปีที่แล้ว

    Please assist how will username and password will be validated as database is not set

  • @Justin-iv7ft
    @Justin-iv7ft 6 ปีที่แล้ว

    Thank you for this. This helped more than anything else in getting auth up and running in my own project. Unfortunately I never get an "Incorrect password error". It returns the "User does not exist one" in all situations.

    • @SubiqT
      @SubiqT 6 ปีที่แล้ว

      It's because in his example he checks if both the username and password match to confirm that the user exists. To fix this you could change it to
      if not user.check_username(username):
      raise forms.ValidationError('User does not exist')

    • @s1ars
      @s1ars 5 ปีที่แล้ว

      @@SubiqT I tried following your suggestion however it threw an error - 'None Type' object has no attribute 'check_username'. i also tried to print the "user" variable after authenticate method is called and each time the user value is returned as None.
      user = authenticate(username=username, password=password)
      print(user)
      if not user.check_username(username):
      raise forms.ValidationError('User does not exist')
      if not user.check_password(password)
      raise forms.ValidationError('wrong password')

    • @SubiqT
      @SubiqT 5 ปีที่แล้ว

      @@s1ars You could check out the method mentioned in this stack overflow post instead stackoverflow.com/a/20012419

  • @kvasok-ml
    @kvasok-ml 4 ปีที่แล้ว

    Thank you

  • @priyankamadhesh7836
    @priyankamadhesh7836 5 ปีที่แล้ว

    I heared Django built-in authentication function is use to generate automatically user registration details but I don't know how to do that can you plz tell me

  • @KiloWhiskay
    @KiloWhiskay 5 ปีที่แล้ว +1

    What IDE are you using?

  • @_ngecu
    @_ngecu 4 ปีที่แล้ว +1

    I followed the whole tutorial to the last full stop then i get an error.I clone the repo i get the same error
    Page not found:
    The current path, accounts/login/, didn't match any of these

    • @nofoobar
      @nofoobar 4 ปีที่แล้ว

      Its an error because the path is not matching what you would have mentioned in your urls.py. Have you included everything in main project urls ?

  • @rohantongle155
    @rohantongle155 5 ปีที่แล้ว +1

    getting attribute error nontype error in check password

  • @abhiruparoy9643
    @abhiruparoy9643 5 ปีที่แล้ว

    return super(UserLoginForm,self).clean(*args,**kwargs)-----super is showing wrong

  • @Thesrik23
    @Thesrik23 6 ปีที่แล้ว

    One question how to render checkboxes in template in Django??

    • @mattfreire
      @mattfreire  6 ปีที่แล้ว +1

      Search on this page for checkboxinput
      docs.djangoproject.com/en/2.1/ref/forms/widgets/

  • @lookback6314
    @lookback6314 5 ปีที่แล้ว

    What does cleaned_data.get() do? I didn't get :|

  • @soncontentmedia
    @soncontentmedia 5 ปีที่แล้ว

    This output form is so ugly, can we customize it?

  • @abhijithm7732
    @abhijithm7732 5 ปีที่แล้ว

    ImportError: cannot import name 'home'

  • @charan5934
    @charan5934 5 ปีที่แล้ว

    hello! iam getting a csrf token missing or error instead of adding {% csrf_token %}in html template

    • @may007ank
      @may007ank 5 ปีที่แล้ว

      Are you setting the method attribute of your form as 'POST'?

  • @derekkroeker4582
    @derekkroeker4582 3 ปีที่แล้ว

    This is the new way of adding the app 'accounts.apps.AccountsConfig'

    • @derekkroeker4582
      @derekkroeker4582 3 ปีที่แล้ว

      Won't work in this tutorial, I got an error and used only 'accounts'

  • @skynet1024
    @skynet1024 4 ปีที่แล้ว

    to the point.

  • @thinkdo9470
    @thinkdo9470 3 ปีที่แล้ว

    good

  • @shashanksharmadon4295
    @shashanksharmadon4295 4 ปีที่แล้ว

    Nice

  • @footballfan7796
    @footballfan7796 6 ปีที่แล้ว

    hello can you help me with a few thing in django ?

  • @ayushagrawal2405
    @ayushagrawal2405 4 ปีที่แล้ว

    How can we decorate our form in html

  • @shashanksharmadon4295
    @shashanksharmadon4295 5 ปีที่แล้ว

    cool

  • @muhammadsalah9598
    @muhammadsalah9598 6 ปีที่แล้ว +1

    God this is so frustrating in flask it's much simpler

  • @sergeymarkov8567
    @sergeymarkov8567 5 ปีที่แล้ว

    I wish you were showing every model separately. It feels so long and boring for my clip mind to follow and just write some text in editor for first 10 minutes. thanks anyway
    if new_video in Just_Django:
    me_happy = True

  • @raomuhammadhamza553
    @raomuhammadhamza553 5 ปีที่แล้ว +1

    bring some more voice out of your mouth i have to put high speaker to listen you

    • @udaykhalsa
      @udaykhalsa 5 ปีที่แล้ว

      be polite or watch another video if you can't be or can't hear. duh.

  • @deki90to
    @deki90to 4 ปีที่แล้ว

    Terrible tutorial

    • @mattfreire
      @mattfreire  4 ปีที่แล้ว

      Care to give some constructive feedback?