Building a user authentication app with React and Django Rest Framework

แชร์
ฝัง
  • เผยแพร่เมื่อ 23 พ.ย. 2024

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

  • @MrJgracias
    @MrJgracias ปีที่แล้ว +17

    Thank you for making the video. It was the first time I have ever had to reduce the play speed!

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

      😂

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

      @@djangoroad it was really good. I need to watch the rest because i don't understand ll of it and I want to you seem like you get it.

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

    i'm not so new to django you got me subscribed right away!
    keep doing the good work brother

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

    So much in 15 minutes! Thanks for this video

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

    that was really awesome, i'v not seen such a tutorial with django and react befor. keep goin dude.

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

    I love your tutorials. Clean and easy.

  • @neliobila
    @neliobila 7 หลายเดือนก่อน +1

    Hi Dotja, thank you for making this video, i would like to see how you protect a page and api from not logged users

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

    I loved your tutorial, very fast and easy to follow, keep up the good work!

  • @NeenuJose-ov7ng
    @NeenuJose-ov7ng 9 หลายเดือนก่อน

    Hi Dotja, thank you for making this video 🙂

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

    Hi I just came across your channel and you're are a real pro at this like you explain everything and make it easy to follow, good job mate

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

      Thank you!

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

      @@djangoroad Hey man so I've been trying to work with djangorestframework but it hasn't been going good, I get errors that djangorestframework could not be resolved when I try to import it and I've tried uninstalling, reinstalling, starting a new project, changing the virtual environment, using the old version and so on. What should I do?

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

      If ur in viscode, do ctrl + shift + P and select ‘Python:Select Interpreter’ and choose ur virtual environment

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

      @@Gyglir Thank you so much bro, I didn't know what to do and was about to give up

  • @Plegeus-qk3jr
    @Plegeus-qk3jr ปีที่แล้ว +4

    I seem to be having issues with authentication. When I do the login everything works, though, when I refresh the page, the frontend does not seem to remember that I was logged in. I made a url in mu users app in Django: /user/authenticate/, the sole purpose is to authenticate a user base on the request (so if request.user.is_authenticated: blah blah), unfortunately this step fails, even when I did not refresh the page from react (and when I did the login successfully). Any ideas what might cause this? When I follow to urls in localhost:8000 and manually do the posts, everything works as expected.

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

    I'm here coz I want to go back to django from node. it's nice there is still tutorials using the session token instead of JWT

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

    This seemed good but am I missing some setup steps? There is a bunch of django boilerplate code that appears right when the video starts without any mention of how to start other than installing 2 dependencies

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

    Awesome video, had to watch it on 0.5x though, but all good! Thank u! 😝

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

    This video is a hidden treasure

  • @aヤハミ
    @aヤハミ ปีที่แล้ว +3

    The operation of writing files regarding "from validations" is not shown in the video, but does it work without writing validations files?

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

      hey ! did u find a solution ?

  • @HalilibrahimDemir-dh7uo
    @HalilibrahimDemir-dh7uo หลายเดือนก่อน +1

    Why can't I see the users in the admin panel after successfully registering.

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

    by far the best.

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

    Very nice tut again, thanks so much : )

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

    Why is it important to use the IP address rather than the localhost alias? In my own project based on this model I am seeing that making requests from localhost seems to have csrf issues. Can you clarify what is happening?

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

    So great!! Thanks for your effort.

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

    Hello! I have an issue with the code. I can not create superuser (user = self.create_superuser(email, username, password)
    [Previous line repeated 989 more times]
    RecursionError: maximum recursion depth exceeded ). The other error is that I can not access to admin panel Exception Value:
    'AppUser' object has no attribute 'is_staff'

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

    Hello, i am totaly 0 in backend but i have to create fullstack app for sceduling school subjects unfortunatly... If i would copypaste this, will i be able to add some roles on this ( like administrator, which would be able to add roles for the certain users etc. etc) ?

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

    If you are familiar with Django, but still trying to make sense of single page applications, this video is gold. You see the serializers, api's, forms, functions and states in action, and you get a working signup / signin / logout application, with not one line of code more than required. Highly to be saluted.
    It took me two evenings to get it working. There were issues with my node, requiring adding two variables in package json, and errors using email to create and authenticate user, so had to replace it with username in both back and front. All seems to work, now I can start learning from it. Thank you so much for this.
    I do have a question. The process uses session authentication, with Django again not making it too difficult to implement, it only seems to be adding some settings and in the code some repetitive snippets. How safe is this application?

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

      Update. I'm 3 weeks into my journey of single page application with React and my head is spinning. I've managed to put the home, signin, signup in separate pages using React Router navigation links. I've separated the user check with Zustand to set a global 'is_authenticated' boolean, and calling it with useEffect on the homepage and profile page I've added. Apparently I have to call this function on all pages where I want to work with logged-in users only? This state concept is so different from Django-only, I can barely wrap my head around it, but I'm guessing this is the stateless vs stateful communication in action. I'm using the user response to display the users data where I want, and added a delete user functionality. After endless tries with post combinations, I finally got it working with a get method. Didn't expect that, not sure if what I'm doing is correct, and still trying to figure out how to delete the cookie, the empty brackets in the authentication classes seem to do that in the logout view, but that doesn't work for deleting users, at least not with my snippet. Some more CRUD functionality, together with error handling, would have been the cherry on the cake. But it's still the best cake out there for React beginners with Django experience. Thank you for this video.

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

      In the mean time I've managed to add some error handling, both on the front upon submit, and from the back catching the status, wuhu. Today I woke up thinking 'but why use serializers if the user submits plain text?' It seems not needed, my login works fine without, but pretty sure I'm overlooking something.

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

      I gave up, Now im using Next

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

    A great tutorial, but doesn't your usermodel implemenation break Django Admin? If I viist /admin route it crashes (eg. 'AppUser' object has no attribute 'is_staff'). Surely it must be possible to have these api register, login etc endpoints but also keep /admin working so that internal staff can manage users, groups, etc?

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

      im having the same issue. Any luck figuring it out?

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

      change the user model AbstractBaseUser to AbstractUser, because when you access with the django admin panel it need the fields like is_staff, and others. 😊

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

    Why do we use the 127 IP address and not the localhost?

  • @al.e.k
    @al.e.k ปีที่แล้ว +2

    Hi!
    It's informative and short video!
    But what would you do if you will need to access same backend api's endpoints both from SPA (like you do in the video) and from another api clients (not browsers)?

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

    Looked good to me, thank you.

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

    Can you explain the same with JWT Authentication(djangorestframework-simplejwt) instead of SessionAuthentication?

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

      Hi, you might be interested in this video I made on JWT and DRF th-cam.com/video/Qx5hDC33xQU/w-d-xo.html
      It's a bit old but might still be useful.

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

      @@djangoroad could u do a video on how to integrate the JWT Auth from DRF with React? Thanks!

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

    I might be missing something but how does a Django server set the browser cookie? It's not being set in the React app so I'm completely baffled how that's being set. Anybody? Thanks

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

    so much information in this video thank you for this

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

    Hi there, I have a question. When you modify the superuser in the user model before modifying it, it works. but when I modify the user for the new user model, it no longer allows me to create a super user, how can I create a separate user model?

  • @Plegeus-qk3jr
    @Plegeus-qk3jr ปีที่แล้ว

    short but complete, I like it, straight to the point. some webcam action at the start for personality? sure! but focus on the code throughout the video, this is what I like to see.

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

    Might be silly question. but unable to find straight answer to it. Why model instances are created in the serializer?

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

    Hi i am stuck at 04:20 where you are using the .validations.I cant seem to understand where it is coming from

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

    Amazing! I still can't get it to work :( I re adjusted my code using yours but I am getting a websocket error! Wish you could assist me with 5 minutes of your precious time!! Your videos are great!

  • @Thomas-sx5uz
    @Thomas-sx5uz 8 หลายเดือนก่อน

    Hi very nice but the problem is that in my react app everuthing is pack in his file and I have the problem of the refreshing of the variable user because my form is not direclty in the app component... How can I handle this problem ?

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

    Very nice and instructive video!

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

    Thanks for the tutorial. Excellent explanation. Can yo repeat the same process for Django Ninja?

  • @ศิวศิษย์แสงนิกุล

    That’s great!! I spent my 5 hour to solve by myself but it’s fail… I will try ur tutorial

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

    Got yourself another sub buddy. Thank you very very much.

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

    Great tutorial. Only thing I saw as feedback is the serialized password is raw and exposed

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

    thx a lot, but here is a problem, it log out automatically after I refreshed my page. why the app didn't keep the sessionid, what should I do

    • @atulgupta-g
      @atulgupta-g 8 หลายเดือนก่อน

      Hey, I am also facing the same issue, did you resolved it yet by any chance?

  • @YashChauhan-c8e
    @YashChauhan-c8e 2 หลายเดือนก่อน

    where is the file validation .py from where you imported the custom_validation .

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

    Hi thanks for the video, but I have to give some tips. Please don't cut the videos randomly because some parts are missing and it makes the tutorial bad for the beginners, you have plenty of time so you don't have to rush.

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

    you are fucking perfect, foud EXACTLY what i was looking for

  • @FrEEze-0716
    @FrEEze-0716 8 หลายเดือนก่อน

    Hi, i am unable to create the superuser and also login to the admin page, if like that how can I check how many users have registered?

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

    Thanks alot, Great Video!
    I just have the problem that I do not have a sessionid cookie don't know what I am doing wrong.

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

    please can you make a video on how we can deploy this app?

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

    Great tutorial, thanks

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

    How can I move the user to the dashboard immediately after registration without having to login

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

    awesome! thank you so much!

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

    thanks for the video. and how to deploy such app in production ?

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

    this is just awesome video

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

    Which version of python you used in this project ?

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

    where is the user_api custom model video link?

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

    excellent example

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

      needed to add CORS_ORIGIN_ALLOW_ALL = True as frontend complained with a CORS error ?

  • @ajay-pi5jj
    @ajay-pi5jj ปีที่แล้ว

    Nice video to brush up same knowledge

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

    Authorization (only admin user can create normal user) how to do this in api

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

    Amazing
    How can I create a Google login authentication django and react js

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

    great work☺

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

    thank you ! i have one question how we connecting django to react front end ?

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

      watch 9:41 to 9:47
      Django's server url is given as baseURL in axios. Later POST requests are made through axios.

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

    Thank you!

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

    Now I can login properly, but I can't logout it said "Request failed with status code 403" even if it works in server-side any suggestion?

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

      I have the same problem probably. The error response message says "CSRF Failed: Origin checking failed - localhost:3000 does not match any trusted origins". And this is the case for all post requests after login. Did you have any luck figuring out what's wrong?

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

      for that case try to use the ip address instead of localhost directly (localhost:3000 -> 127.0.01:3000) this method works for me.

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

    Thanks ❤

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

    Thank you

  • @ShivamSharma-if1oh
    @ShivamSharma-if1oh 8 หลายเดือนก่อน

    Thanks

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

    Where is the validation file?

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

    I mean Im using Tailwind but good video

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

    for me /api/user is giving me Forbidden: /api/user .....How to fix this ?

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

      Hi, have you solved the problem?

    • @edwin.niwaha
      @edwin.niwaha 9 หลายเดือนก่อน

      the same issue here

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

    my password is not being hashed when creating a new user, what could be wrong?

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

      Ensure your create method for the registration serializer isn't under the meta class and is a direct child of registration serializer. It sounds like your serializer is using the create function from the inherited serializers.ModelSerializer class.

    • @dani-xi4zd
      @dani-xi4zd ปีที่แล้ว

      @@persepofficial4215 I am new to django and my mistake was that I wasn't rewriting the method of the parent class in the current class, I thought I could name those methods (on the current class) as I wanted LOL, and after some hours I finded out that my method wasn't the same as the one in the video, then I fixed it all worked just fine. Btw thanks for your reply.

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

    good video, but too fast and hard to follow...

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

    My brother, please, my only singular gripe is that I can hear the molecules of liquid moving around in your mouth with every small movement.
    Please lower your gain, or figure out where the suppression gate is on your mic software.

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

    What's the point of showing only some steps required in the video? It's missing a lot of stuff and it's incomplete. Waste of time

  • @koalawanted5662
    @koalawanted5662 9 หลายเดือนก่อน +1

    is that women or men?

  • @lecturer4912
    @lecturer4912 ปีที่แล้ว +7

    I don't understand why you make incomplete videos without specifying it's incomplete. You will make newbies frustrated trying to follow your tutorials. No models in this project? No database and migrations?

    • @peanutbutter8242
      @peanutbutter8242 ปีที่แล้ว +7

      if ur a newbie learn django first and dont jump intp restapi
      like no offense bro

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

      This is a video about REST authentication, not about basic Django setup. Plus if the author would’ve decided to include those things you’re talking about, video would have been much longer!

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

      dont mind this guy, the video is great! i want to know how react and django play together, this shows exactly that. Great stuff.

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

    Thank you