Django Authentication & User Management - Full Tutorial

แชร์
ฝัง
  • เผยแพร่เมื่อ 1 ก.ค. 2024
  • Welcome back to another video! In todays video I am going to be showing a Django tutorial on how to setup authentication for a Django website, like how to create new users, have them sign in and sign out of their accounts! I'll also talk to you about permissions and groups and how to assign specific permissions to users and restrict parts of the website to those users. Overall, this will give you an in-depth understanding of the Django permission system and grouping and allow you to do some advanced stuff for your own website! I hope you learn something and enjoy the video!
    💻Thanks to Retool for sponsoring this video! Get started building interactive and visual dashboard for FREE: retool.com
    Check out the Retool TH-cam channel! / retool
    💻 ProgrammingExpert is the best platform to learn how to code and become a software engineer as fast as possible! Check it out here: programmingexpert.io/tim and use code "tim" for a discount!
    📄 Resources 📄
    Code In This Video: github.com/techwithtim/Django...
    Django Auth Docs: docs.djangoproject.com/en/4.0...
    Heroku Dashboard: dashboard.heroku.com/login
    Bootstrap: getbootstrap.com/docs/5.1/get...
    Django For Beginners: • Django For Beginners -...
    Fix Pip (Windows): • How to Install Pygame ...
    Fix Pip (Mac): • How to Install Pygame ...
    ⭐️ Timestamps ⭐️
    00:00:00 | Video Overview
    00:01:04 | Retool
    00:02:16 | Project Demo
    00:03:58 | Django Setup & Installation
    00:11:22 | Writing HTML Templates
    00:21:54 | Remote Postgres Database Setup
    00:28:20 | Retool Dashboard Setup
    00:33:18 | Django User Registration & Sign In
    01:00:48 | Creating Posts
    01:13:28 | Viewing Posts
    01:18:09 | Deleting Posts
    01:25:55 | Groups and User Permissions
    01:58:34 | Banning Users
    02:09:28 | User Stats and Dashboard
    ◼️◼️◼️◼️◼️◼️◼️◼️◼️◼️◼️◼️◼️◼️
    👕 Merchandise: teespring.com/stores/tech-wit...
    📸 Instagram: / tech_with_tim
    📱 Twitter: / techwithtimm
    ⭐ Discord: / discord
    📝 LinkedIn: / tim-ruscica-82631b179
    🌎 Website: techwithtim.net
    📂 GitHub: github.com/techwithtim
    🔊 Podcast: anchor.fm/tech-with-tim
    🎬 My TH-cam Gear: www.techwithtim.net/gear/
    💵 One-Time Donations: www.paypal.com/donate?hosted_...
    💰 Patreon: / techwithtim
    ◼️◼️◼️◼️◼️◼️◼️◼️◼️◼️◼️◼️◼️◼️
    ⭐️ Tags ⭐️
    -Tech With Tim
    -Django Authentication Tutorial
    -User Management Tutorial
    -What is Django
    -Retool
    ⭐️ Hashtags ⭐️
    #TechWithTim #Django #Authentication

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

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

    You are just so perfect Tim. Words can't express how grateful I am

  • @zeroday6379
    @zeroday6379 ปีที่แล้ว

    You have saved me big time on figuring out important basics. Thanks man.

  • @tomasgorda
    @tomasgorda 2 ปีที่แล้ว +14

    Nice video, thanx again. One thing i have to mention: in a lot of your tutorials you are using a lot of external addons or resources (heroku, linode, retool etc…), but when you developping an applications for company with some security rules, mostly you have no chance to use any of them. So better is to use your local resources. Next think is a lot of registrations around these public resources.

  • @matt-xq1xv
    @matt-xq1xv 2 ปีที่แล้ว +2

    dude your videos are so good. i learned so much from them. thank you for making this awesome content.

  • @TheNerdyPlayer
    @TheNerdyPlayer 2 ปีที่แล้ว +1

    this is exactly what i was looking for :) love your videos

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

    Awesome I really was searching for these kinda videos thanks so much ❤️

  • @krzysztofwachowiak8547
    @krzysztofwachowiak8547 ปีที่แล้ว

    Thanks. In your guide, I found the answer on how to properly define permission checking in views.

  • @rinoldaiman6441
    @rinoldaiman6441 ปีที่แล้ว

    Thanks a lot bro. I was not able to authenticate new user but after watching this video it took only 2 mins to solve my problem which I was facing for more than 3 hours.

  • @blazenetic
    @blazenetic ปีที่แล้ว

    Epic content mate! Fantastic stuff, you are a great teacher.

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

    I just finished to watch your first django tutorial, and now I'm going to eat and digest this 1 xDDDD. It's incredible how much I've learned from you. You are a legend!

    • @TechWithTim
      @TechWithTim  2 ปีที่แล้ว +1

      Hope you enjoy!

    • @sizu257
      @sizu257 2 ปีที่แล้ว +1

      @@TechWithTim You, Bucky Roberts, Giraffe Code Academy, Code Beauty, Computer Science Crash Course, Ben Eater, and all the community out there, you are my heroes! But from all, you taught me the most. Python, MySql, Django, Speech Recognition, Pygame, Clients with Sockets, and many, many others. Because of you, I know how to build my humongous project, that hopefully's going to change the shape of the world. I thank you with all my might!

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

    We just started using django at work! Thanks :)

  • @alfabetony
    @alfabetony 3 หลายเดือนก่อน

    loved that you used retool. working with the shell is hell to someone who doiesn't know much sql. Watching database changes via retool makes it seems so much nicer and sleek. The interface has changed since you made the video so i couldn't keep up with some of the retool stuff but i got the gist and will definitely look into using retool in the future.

  • @zeydtc
    @zeydtc ปีที่แล้ว

    This is really good. Thank you!

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

    Awesome! This is really helpful!!

  • @usmanmonir5576
    @usmanmonir5576 11 หลายเดือนก่อน +1

    Tutorial was awesome 👏 and have learnt a lot! One thing is while banning user the filter function was correct u just have to put .first() at the end as u did for the user, also for getting user u can simply use get function to be consistent. Thanks for such a great content!!!

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

    Hello Tim.Thank you for the cool tutorial. Helped a lot to understand the approach of permissions.
    Also, I have forked the project to propose a different way of removing the user from the groups, and to add a user to the group 'default' upon sign-up. Hope you find it useful and that I did not make the repo dirty.
    Take care and keep up with these sweet tutorials.

    • @murshid956
      @murshid956 2 หลายเดือนก่อน

      Is this video applicable to the django rest framework?

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

    Tim I have a tip regarding what you showed :D If you are in an empty html file you can type one "!" and just press TAB! :D It will get you the same boilerplate html but faster. Keep up the great work!

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

    You teach many things. Keep it up✊✊✊

  • @pravachanpatra4012
    @pravachanpatra4012 2 ปีที่แล้ว +13

    LETS GOO!!! Tim finally making DJANGO tutorials. We need a social media clone next.

  • @javalex561
    @javalex561 5 หลายเดือนก่อน

    Tim, you are the GOAT, would you please make a new video about Django 2fa?

  • @roronoa_shady3269
    @roronoa_shady3269 2 ปีที่แล้ว +20

    Hey, Tim. I have been watching you for several years and I really like your content, the way you explain and show new things to us is great. I have learned a lot from you, also modified some of your projects. Really liked that video. And I was hoping you could make a video about AI - translator.

    • @amirilifee
      @amirilifee 2 ปีที่แล้ว +3

      let this comment be on the top)

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

    Thanks for your suport for uploading these videos

  • @justme-dz1wy
    @justme-dz1wy 11 หลายเดือนก่อน

    Thank you Tim.🙏

  • @manu-gt9gr
    @manu-gt9gr 2 ปีที่แล้ว +1

    nice video bro!

  • @valera723
    @valera723 ปีที่แล้ว

    Hi thanks very much for this tutorial. Can you tell please what extensions do you use in the editor ?

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

    Thanks,very nice awesome content

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

    Seems to be a nice tutorial

  • @gramscihc7131
    @gramscihc7131 28 วันที่ผ่านมา

    Hey Tim, first you Rock, and second could you let me know what vscode extension you use for django templates, Thanks

  • @ComputerGeek1100
    @ComputerGeek1100 2 ปีที่แล้ว +1

    Just wondering - what are you using for the syntax highlighting in the HTML templates? I’ve noticed that the default HTML intellisense in vscode doesn’t do that with the Django tags

  • @anashoussaini3915
    @anashoussaini3915 2 ปีที่แล้ว +11

    Thank you for the video, really well done. Although, I must say for Retool, I think it would be better to the admin panel by yourself. You will learn a lot by doing so. If someone is trying to build a web app with Django, it's impossible that they aren't programmers.

    • @armsjarbcgaming1591
      @armsjarbcgaming1591 10 หลายเดือนก่อน

      agreed, nifty tool tho

    • @shahinhashemi5799
      @shahinhashemi5799 9 หลายเดือนก่อน

      I assume it was done this way to plug Retool which is the sponsor

  • @kaosang6754
    @kaosang6754 4 หลายเดือนก่อน +2

    how do you fix the logout one? when i go to the logout it displays a blank page

  • @zeroday6379
    @zeroday6379 ปีที่แล้ว

    Great content. I have tried to modify the signup page to incorporate things like phone number and country, however, these changes appears at the frontend and doesn't appear on the database, is there something I am not doing right?

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

    38:48 Just a small hint: Don't use links that only contain the word "here". People who can't see well often use screen readers, which most of them have the ability to list out all links from a site. If the links now just contain the word "here", the person won't know where they'll be going.

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

      skill issue

    • @NeoShinkai
      @NeoShinkai ปีที่แล้ว

      @@armalite6837 no funny

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

    Is any more go projects on the pipeline or was the api vedio last in that series

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

    Great 👌💯

  • @aayushshrestha1210
    @aayushshrestha1210 หลายเดือนก่อน +2

    if the /logout doesn't work
    add
    def LogOut(request):
    logout(request)
    return redirect("/login/")
    to your views and create a custom url at the top of the urls file
    path("logout/", views.LogOut, name="logout"),

  • @juiceearthhh7225
    @juiceearthhh7225 6 หลายเดือนก่อน +1

    do you have a django rest framework course

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

    nice one @Tech with Tim. Can this be used with a REST or GraphQL API? Or do you have any tutorial you'd recommend for that?

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

      Yes, You can use REST API with Django, not sure about GraphQL!

  • @ahmedkhaldi2057
    @ahmedkhaldi2057 10 หลายเดือนก่อน

    thanks

  • @sidharthcs2110
    @sidharthcs2110 3 หลายเดือนก่อน

    How does login and logout work if the APIs are called from something like postman ?
    what information is letting the system know which user is trying to logout ?

  • @EDWIN-zg4yu
    @EDWIN-zg4yu 3 หลายเดือนก่อน

    first off, what others tutorials do you have about Django? And second, could I modify the post part so that my admin users can upload Docker files instead of only text?

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

    Please make more advance project in django

  • @TheIvanlisi
    @TheIvanlisi 10 หลายเดือนก่อน +1

    Do you have logout option in the code?

  • @k-kamori8842
    @k-kamori8842 ปีที่แล้ว

    Hello, I have encountered a UserCreationForm error. It says "cannot import name 'usercreationform' from partially initialized module". How do I fix this?

  • @rec-trick
    @rec-trick 3 หลายเดือนก่อน

    awesome

  • @pryme0
    @pryme0 3 หลายเดือนก่อน

    when doing pip install crispy-forms
    ERROR: Could not find a version that satisfies the requirement crispy-forms (from versions: none)
    ERROR: No matching distribution found for crispy-forms

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

    Hey Tim, Its a great video thank you so much. Just got a little problem with the postgres database, heroku doesn't offer free tiers any more and I tried using Linode instead but I was unable to connect to my database and I finally gave up on using postgres. Could you make a video explaining how to setup postgres database on linode and connect it with django it would be so much of a help thanks
    🙏🙏

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

      I got the same problem here. It's not free anymore 😥

    • @besma702
      @besma702 9 หลายเดือนก่อน

      Did you other solution??

  • @tommasol.m.a.giambelli1643
    @tommasol.m.a.giambelli1643 2 ปีที่แล้ว

    Hi Tim!
    Quick question: why do you need a specific sign-up url and not need a login url?
    Is it because you expanded the pre-built sign-up class?

  • @Kappq
    @Kappq 2 ปีที่แล้ว +1

    The fact that just today I was trying to setup user authentication with Django and this video comes up- please remove the hidden cameras from my house. 😭😂

  • @jessicam3256
    @jessicam3256 ปีที่แล้ว

    Thank you for this amazing video! But I was stuck at the retool dashoboard setup, after I entered "select * from pg_catalog.pg_tables", i got an error of "self signed certificate"... anyone knows how to solve it? @@

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

    what if I want to use a normal database? how would it be done?

  • @ohisideho3460
    @ohisideho3460 หลายเดือนก่อน

    Heroku is not freen anymore. Any other services you suggest to follow along with the tutorial?

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

    Is this something we can put on our resume?

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

    nice

  • @amitavasengupta5580
    @amitavasengupta5580 5 หลายเดือนก่อน

    2:04 hrs why can't we import the Group and post_save globally?

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

    Do you have the beginning django?

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

    Y don't you map login in url..is it is a built-in function in python

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

    Please make course on django-4

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

    how to solved thik pblm plz?
    Query ran successfully
    statusCode:404
    error:"Not Found"
    message:"Unable to retrieve information about the query "query2""
    data:null

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

    Is this for beginners too?

  • @dennisdegraphicsdynamo_999
    @dennisdegraphicsdynamo_999 3 หลายเดือนก่อน +1

    Hello @Tim I know this video is a year now....but please comment on this post. I wanna know how I will deploy my code since heroku is dead....no more free offers. Please tell me the best option to do. I need your reply as fast as possible please

  • @shibmobileverse468
    @shibmobileverse468 ปีที่แล้ว

    Can anyone else use the SSL? I had to disable it in Retool and skip certificates in order for it to connect. :( (Free Version of both Heroku + Retool)

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

    This isn't fair. watching such an amazing video with 1.12million views and getting only 1.2k likes
    come on guys you can do better

    • @omarjones8481
      @omarjones8481 5 หลายเดือนก่อน

      maybe because a lot of us can't finish being that Heroku isn't free and that stopped the viewing on a bad note

  • @ILCGyangcczmyiyan
    @ILCGyangcczmyiyan 7 หลายเดือนก่อน

    what happens if I dont use crispy, I just type form.as_p

  • @learnwithbasics6478
    @learnwithbasics6478 8 หลายเดือนก่อน

    brother is saving me from C++ class to software engineering class. Just a little too fast.

  • @motlatsimoea5615
    @motlatsimoea5615 9 หลายเดือนก่อน

    So I tried to customize the "password_change" Auth by creating a template with the same name and for some reason it keeps sending me to that default template.
    Any idea why?

    • @vaqmad
      @vaqmad 8 หลายเดือนก่อน

      Actually you need to point the other template, or ovevwrite the existing by creaating template with correct name of file

  • @vaqowski6669
    @vaqowski6669 8 หลายเดือนก่อน +1

    1:22:17 ( ͡° ͜ʖ ͡°)
    Anyway i have a little bit of constructive comments about the tutorial. I hope it would be helpfull in the future tutorials. First of all i think that sticking to the general programming good practises would be a great idea. For example if you are creating a template, a view, a model or a form let it handle just one thing. For example separte templates for navbar, creating post, ect. Or you are useing a lot of logic inside home view, i would separate the logic to the differrent functions - so it allows me to stick to the KISS and SOLID principles.
    But besides that great tutroial, You explained very solid how to use User model from django and also generic forms it gaves me a lot of understanding which i didnt have before watching, thanks.

  • @TomStoutPhotography
    @TomStoutPhotography ปีที่แล้ว

    Couldn't get psycopg2 to install...wish. you weren't using heroku.

  • @omoraltanim5795
    @omoraltanim5795 4 หลายเดือนก่อน +2

    57:24 From Django 4.2 logout through GET is depreciated. Use this instead of link to logout
    {% if user.is_authenticated %}
    Logged in as {{ user.username }} |
    {% csrf_token %}
    Logout

    {% else %}
    Login
    {% endif %}

    • @kranfundefined
      @kranfundefined 4 หลายเดือนก่อน

      You are almost right, we need to paste in action "{% url 'logout' %}" not 'admin:logout'

  • @BGOPC
    @BGOPC ปีที่แล้ว

    i don't want to disrespect but i guess i'm more expert in django
    CSRF token is a special type of web token used to authenticate
    it's a hidden input with special value which will be your auth key at the server

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

    You are using re-tool and there django admin panel is like :|

    • @noajm4628
      @noajm4628 3 หลายเดือนก่อน

      What do you mean*_

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

    ayo tim

  • @jdchannelviewer
    @jdchannelviewer ปีที่แล้ว +3

    FYI: I don't think Heroku is free anymore.

    • @growlinghuel9766
      @growlinghuel9766 ปีที่แล้ว

      Worth pointing out. I've started a few different tutorials and stopped at the point when they tell us we'll require Heroku to complete the work.

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

    Is this is for begineers..

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

      Django itself is pretty beginner friendly, this specific tutorial is not really :(

  • @shans1308
    @shans1308 9 หลายเดือนก่อน

    23:35

  • @uclocnguyenvo422
    @uclocnguyenvo422 ปีที่แล้ว

    57:34 It is confused for me right here. How can the base.html know the variable user if we do not pass it from the view?

    • @kidjr.9520
      @kidjr.9520 11 หลายเดือนก่อน

      Because of the request. that we are sending .When you are not logged in in your request will be shown as anonymous user whereas if you are logged in your user information will be passed with the request.

  • @13137713
    @13137713 8 หลายเดือนก่อน

    Jenga 😅

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

    The youtube algorithm wants short videos, I understand that. 'Short videos' means a lot of information in a very short amount of time. I'm already not a fan of that, but I really don't understand why you're going THAT fast in your video with so little explanation about what your doing. This is a 2 and a half hour video, it's a bloody TUTORIAL made for people who want to learn. This should have been a 5-hour-long video and if people aren't interested in one of the topics they can simply skip it. Learning in these conditions is just horrible and if I had a professor that was teaching that way, I'd never show up to the classes. I hope this was good criticism.

  • @yogeshshrestha1745
    @yogeshshrestha1745 ปีที่แล้ว

    Thankyou sir I got my answer you helped a lot

  • @soumenchattopadhyay9612
    @soumenchattopadhyay9612 6 หลายเดือนก่อน

    for me LOGOUT_REDIRECT_URL = '/login' not working it says "Method Not Allowed": /logout/ .. I am in Chapter - Registration and Sign in

  • @jeromepouzoulet7823
    @jeromepouzoulet7823 7 หลายเดือนก่อน

    Great Tutorial. You covert every aspects and you go to the point like a boss, well done. Thanks!!!

  • @melancholicsmile5575
    @melancholicsmile5575 6 หลายเดือนก่อน

    Hi Tim I Modified The code to This for Banning user So it will auto remove from all groups
    elif request.POST.get('ban_user_id'):
    ban_user_id = request.POST.get('ban_user_id')
    user_id = User.objects.filter(id=ban_user_id).first()
    if user_id and request.user.is_staff:
    groups = user_id.groups.all()
    print(groups)
    if not groups :
    messages.info(request, f'User:{user_id.username} is already Banned')
    else:
    for group in groups:
    user_id.groups.remove(group)
    user_id.save()
    home.html
    add this right after {%block content%}
    {% if messages %}

    {% for message in messages %}

    alert('{{ message }}');


    {% endfor %}

    {% endif %}