How to Handle User Authentication in Django

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

Комментарии • 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!
    ***

  • @mr-engin3er
    @mr-engin3er 4 года назад +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.)

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

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

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

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

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

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

  • @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😢😢😣🙏😣😢😢

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

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

    Great Vid! What theme are you using in VS_Code

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

  • @thebaldguy458
    @thebaldguy458 Год назад

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

  • @thebaldguy458
    @thebaldguy458 Год назад

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

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

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

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

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

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

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

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

    Very good tutorial

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

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

    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

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

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

    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?

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

    why email2 field is not showing ?

  • @satisha7280
    @satisha7280 6 лет назад +1

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

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

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

    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

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

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

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

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

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

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

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

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

  • @kedharchundu5182
    @kedharchundu5182 6 лет назад +1

    Thnqqqq so much sir

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

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

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

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

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

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

  • @ahmedabdelhak8477
    @ahmedabdelhak8477 5 лет назад +2

    thank you for this cours

  • @kvasok-ml
    @kvasok-ml 4 года назад

    Thank you

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

    how can we add sessions to this page please guide

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

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

    What IDE are you using?

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

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

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

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

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

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

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

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

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

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

    to the point.

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

    getting attribute error nontype error in check password

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

    Nice

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

    ImportError: cannot import name 'home'

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

    good

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

    How can we decorate our form in html

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

    cool

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

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

  • @muhammadsalah9598
    @muhammadsalah9598 5 лет назад +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 4 года назад

      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?