Django Rest Framework Series - Permissions and Custom Permissions - Part-2

  Рет қаралды 68,529

Very Academy

Very Academy

Күн бұрын

Hello, and welcome to the second tutorial in this Django Rest Framework Series. In the following series of tutorials we will go through the Django Rest Framework and in addition build a React application to consume our Django Rest API. In this tutorial we review Django Rest Framework permissions applying to the project level, view and object level. We then go ahead and build a custom permission which then leads us to testing our new permissions.
🎉More from this Django Rest Framework Series:
• Learn Django Rest Fram...
🐱‍🏍Introduction
00:00 Series overview and tutorial breakdown
🐱‍🏍Permissions
02:51 Project level permissions
07:04 Create new user & apply Django object permissions
10:36 View level permissions
14:26 Activating user login URLs for the APIview
19:15 Mapping User Permissions to HTTP Requests
20:47 Creating a custom permission
🐱‍🏍Testing
31:15 Testing the custom permission
Code Repository:
github.com/veryacademy/YT-Dja...
github.com/veryacademy/YT-Dja...
github.com/veryacademy/YT-Dja...
👍SUBSCRIBE to get more free tutorials, courses and code snippets!
/ @veryacademy
👍👍Follow us on Facebook
/ veryacademycom-1132321...
👍👍👍Follow use on Twitter:
/ veryacademy

Пікірлер: 87
@anand_dudi
@anand_dudi 2 жыл бұрын
i have gone throught so many youtube tutorials,videos but never got understand in depth how rest is actually works and landed here now everything is crystal clear
@adahal39
@adahal39 3 жыл бұрын
A pure Gold content, A solid series in youtube not only in using the framework but understanding entire web development.
@veryacademy
@veryacademy 3 жыл бұрын
👍
@mohammedezzi6096
@mohammedezzi6096 3 жыл бұрын
A beautiful series (all the series in the channel) with great content well presented and organized with a lot of effort, congratulations
@VskiDevs
@VskiDevs Жыл бұрын
agreed
@alpstinger5083
@alpstinger5083 3 жыл бұрын
This was so beautifully explained! Your voice is so soothing and reassuring. Thanks for posting!
@veryacademy
@veryacademy 3 жыл бұрын
You are so welcome!
@punch12341
@punch12341 3 жыл бұрын
Thank you so much. This is exactly what I needed, your lectures help me a lot especially the testing part
@mateusjunior1937
@mateusjunior1937 3 жыл бұрын
so far , so good, rarely found a video tuto ,which explain the step by step like this , thx again ...
@veryacademy
@veryacademy 3 жыл бұрын
Glad it helped 👍
@TheBodybuildingG
@TheBodybuildingG 3 жыл бұрын
Nicely done , logical flow of information and examples.
@MrKeepItTrill
@MrKeepItTrill 2 жыл бұрын
Amazing tutorial, great to focus on writing tests right from the start, here's your comment for the algorithm :)
@mostafarafid3593
@mostafarafid3593 3 жыл бұрын
Better than many paid django-rest courses....Keep it up...your channel is definitely gonna grow.
@veryacademy
@veryacademy 3 жыл бұрын
Thank you 👍
@samjoel4152
@samjoel4152 3 жыл бұрын
Awesome in-depth videos with theory good work👍👍pls keep this going...
@veryacademy
@veryacademy 3 жыл бұрын
Thanks, will do! 👍
@abdelhamidrobaa
@abdelhamidrobaa 2 ай бұрын
Amazing explanation , specially testing part!
@tarassavchenko2317
@tarassavchenko2317 3 жыл бұрын
I will comment just so youtube improve it algorithm high-quality content here
@veryacademy
@veryacademy 3 жыл бұрын
Thank you! Love your approach to the algorithm - every little helps
@docetes
@docetes 3 жыл бұрын
As usual.... top stuff!
@veryacademy
@veryacademy 3 жыл бұрын
Thanks again! 👍
@felixfigueroa
@felixfigueroa 2 жыл бұрын
You are the best ..Zender.. ! Thank you so much..!
@veryacademy
@veryacademy 2 жыл бұрын
You're welcome!
@shahlagaribi7968
@shahlagaribi7968 11 ай бұрын
you explain very clearly. thanks😍
@Omar_Thinks
@Omar_Thinks 3 жыл бұрын
Wonderful video. Thank you! :)
@veryacademy
@veryacademy 3 жыл бұрын
Thank you too!
@elonmusk2142
@elonmusk2142 3 жыл бұрын
Thank you bruh . keep up dont loose your motivation god blesses you
@veryacademy
@veryacademy 3 жыл бұрын
👍
@mahmudsajib8648
@mahmudsajib8648 3 жыл бұрын
Love you for your effort ❤
@veryacademy
@veryacademy 3 жыл бұрын
Thank you so much 😀
@nicocouss7849
@nicocouss7849 3 жыл бұрын
Really nice serie, thx a lot!
@veryacademy
@veryacademy 3 жыл бұрын
You're very welcome!
@kaushik.aryan04
@kaushik.aryan04 Жыл бұрын
YOU ARE AMAZING DUDE
@veryacademy
@veryacademy Жыл бұрын
Too kind
@FreeDomSy-nk9ue
@FreeDomSy-nk9ue 2 жыл бұрын
Dope. That was really really helpful Wish me luck while I update my project to use DRF
@veryacademy
@veryacademy 2 жыл бұрын
Best of luck!
@radosawskabania1529
@radosawskabania1529 2 жыл бұрын
Great video!
@abhikb
@abhikb 3 жыл бұрын
very helpful video sir thanks for making this series
@veryacademy
@veryacademy 3 жыл бұрын
Most welcome
@igormundim
@igormundim Жыл бұрын
Aula muito boa!
@paborlouise319
@paborlouise319 3 жыл бұрын
Thanks Sir. Great work.
@veryacademy
@veryacademy 3 жыл бұрын
Thank you - any question or issues just let me know.
@user___01
@user___01 3 жыл бұрын
This series is so helpful but I do want to ask a question how do you implement an IsOwner custom permission if you have many-to-many field for like the author in this example. What I mean is that only the authors who has the permission to modify the post.
@dennisasamoah2213
@dennisasamoah2213 2 жыл бұрын
great video as usual
@veryacademy
@veryacademy 2 жыл бұрын
🙏
@diegobraga2207
@diegobraga2207 3 жыл бұрын
your tutorials are the best!! could you make an tutorial how to make I like button in both sides django and react?
@chukwuka-steveorefo1812
@chukwuka-steveorefo1812 Жыл бұрын
Hi Zander, I was wondering why do we extend the Custom class as well and pass it to the persmissions_classes array for the detail view?
@eagleofsharm
@eagleofsharm 3 жыл бұрын
Golden Inf, THANK YOU
@user-dh8dd3pe1i
@user-dh8dd3pe1i 3 жыл бұрын
Nice sir keep it up 👍💪💪💪
@veryacademy
@veryacademy 3 жыл бұрын
Thank you, I will 🐱‍🏍
@mr.anderson5393
@mr.anderson5393 Жыл бұрын
Great video sir. I have a question. In order for custom permission to work in the views, do you need create 'Group' and set 'User Permission ' in the admin panel? For some reason custom permission does not work - the custom permission in Detail view do not give PUT, DELETE . only read-only.
@rangabharath4253
@rangabharath4253 3 жыл бұрын
Awesome
@veryacademy
@veryacademy 3 жыл бұрын
Thank you 👍
@aashayamballi
@aashayamballi 3 жыл бұрын
Thank you 🙏🏼🙏🏼
@veryacademy
@veryacademy 3 жыл бұрын
You are so welcome 👍
@anshuldubey9193
@anshuldubey9193 3 жыл бұрын
Amazing content! I do have a question for you. How would you set the custom permissions if for example a User belongs to a company and there are several companies with several users and you want to only return the data belong to a specific company depending on the user that's logged in! Kind of like a dashboard shared between several companies. Would you request something like user.company (from the user model) and filter the query object? I apologize if my question doesn't make any sense. Thanks
@user___01
@user___01 3 жыл бұрын
this is also my problem @Anshul Dubey do you got an answer or solution to this?
@mohmedAhmed-jo3pe
@mohmedAhmed-jo3pe Жыл бұрын
@@user___01 up
@KatuninPavel
@KatuninPavel 3 жыл бұрын
What is the point of extending PostUserWritePermission in PostDetail class? Why should View class be extended from Permission? You already used composition by setting permission_classes Tuple.
@whichdude420
@whichdude420 3 жыл бұрын
Django Rest Framework tutorial marathon lets goooo
@veryacademy
@veryacademy 3 жыл бұрын
It really feels that way 😂 another big one tomorrow JWT Authentication front and back-end!
@KrishnaManohar8021
@KrishnaManohar8021 3 жыл бұрын
@@veryacademy Waiting...
@abdelrhmanahmed1378
@abdelrhmanahmed1378 3 жыл бұрын
when we create a post using the post view why it didnot saved in the temporary database ?!
@abdelrhmanahmed1378
@abdelrhmanahmed1378 3 жыл бұрын
how can we store the author name also in the post model ,so we can retrieve it when we serialize
@gaborlakatos882
@gaborlakatos882 3 жыл бұрын
My question is that how could you understand the documentation of this permission section on the webpage. I read through it and I got so confused.
@veryacademy
@veryacademy 3 жыл бұрын
I know how you feel, sometimes they are not very friendly. As you knowledge of code and Django develops you will understand it more so. 👍
@FreeDomSy-nk9ue
@FreeDomSy-nk9ue 2 жыл бұрын
Is it possible to do this with django templates? How would you pass the data to the templates (just like it's done with pure django) but using rest framework? I'm trying to get the advantage of object level permissions and also keeping the door open for a future use of react etc...
@veryacademy
@veryacademy 2 жыл бұрын
I think I covered some of your question not too long ago in a mini series. I have yet to get to permissions with the API. My wife keeps asking will I run out of content. I just smile, by the time I get around to everything just Django related, Django would have changed so much I would have to re-make all the tutorials again.
@FreeDomSy-nk9ue
@FreeDomSy-nk9ue 2 жыл бұрын
@@veryacademy That is so true. Don't forget plenty of available extensions. I don't know if you've already covered django-channels but it's really big and fun to make things with.
@xVeraldi
@xVeraldi 2 жыл бұрын
is there a way to restrict someone from creating a Post as another user? looks like your user aaaa can create a post as admin
@veryacademy
@veryacademy 2 жыл бұрын
Hi Rafael, indeed we can. Take a look at creating some permissions. Won’t be too long now I will be creating a series of tutorials on the topic. It is one of the most requested topics.
@harshbiyani3048
@harshbiyani3048 5 ай бұрын
Why do we need to Inherit PostUSerWritePermission ? Will mentioning this class as permission_classes won't suffice ?
@veryacademy
@veryacademy 5 ай бұрын
While directly mentioning the class in permission_classes might work in some cases, using a custom permission class provides a more modular and maintainable approach, especially as your application grows in complexity.
@harshbiyani3048
@harshbiyani3048 5 ай бұрын
@@veryacademy can you please elaborate more, i dint get the part that it may work in some cases also inheritance is different than setting an attribute, hency why do we need to inherit when official document says to pass it as a value to permission_classes attribute
@cherryass99
@cherryass99 3 жыл бұрын
Apparently I can login using DRF web login only with superusers. Non-superusers throw "Please enter a correct email and password. Note that both fields may be case-sensitive.", however credentials are correct :(
@ericksonboang
@ericksonboang 3 жыл бұрын
same problem
@suavementelucas7351
@suavementelucas7351 2 жыл бұрын
and if I want to list only the posts of the logged in user?
@veryacademy
@veryacademy 2 жыл бұрын
You need to create a query for example - Post.object.filter(user=1)
@jeraldjoshuaechavia1108
@jeraldjoshuaechavia1108 3 жыл бұрын
On testing the permission I got an error when test posting the author with errors "{'author': [ErrorDetail(string='Invalid pk "1" - object does not exist.', code='does_not_exist')]}" Is this because the model is a foreign key? Is there any solutions that could help me, btw i'm using MySQL and Axios not Fetch and sqlite3
@veryacademy
@veryacademy 3 жыл бұрын
Sounds like there is no data in the database or you are selecting the wrong data in the database?
@Pavel-er4hy
@Pavel-er4hy Жыл бұрын
Hello! I express my gratitude for the lessons. I have a question : when i make test i get: return _bootstrap._gcd_import(name[level:], package, level) File "", line 1030, in _gcd_import File "", line 1007, in _find_and_load File "", line 984, in _find_and_load_unlocked ModuleNotFoundError: No module named 'rest_framework' Who got result of test like my? And find good soluiton...
@quizandfun_
@quizandfun_ 11 ай бұрын
I wanted to get your courses through Udemy Business, but out of 9 only 2 of your courses were available. Can you make all of your courses available in Udemy Business?
@veryacademy
@veryacademy 11 ай бұрын
Do me a favor and ask/beg Udemy customer services, I have no control over it.
@usamashehab9319
@usamashehab9319 2 жыл бұрын
Sir i noticed two problems First one is with prepopulated slug ,when i use django admin dashboard to create post slug prepopulated correctly but when use rest api to create post the slug field doesn’t prepopulated, it’s empty field The second problem is with DjangoModelPermissions i gave user only add permission and it works fine with django admin dashboard and i just can add and can’t read ,but in rest api the user can read ,add, delete I hope you sir answer me or give me resources to understand the reasons of these problems
@veryacademy
@veryacademy 2 жыл бұрын
Really sorry it is difficult to help you in a meaningful way. I have noted the issues and will use it to deliver further content.
@paycation3966
@paycation3966 4 ай бұрын
15:57 forgot the password, hahaha
Learn Django - Build a Custom User Model with Extended Fields
39:42
Heartwarming moment as priest rescues ceremony with kindness #shorts
00:33
Fabiosa Best Lifehacks
Рет қаралды 37 МЛН
Slow motion boy #shorts by Tsuriki Show
00:14
Tsuriki Show
Рет қаралды 5 МЛН
ЧУТЬ НЕ УТОНУЛ #shorts
00:27
Паша Осадчий
Рет қаралды 6 МЛН
Multiple User Types | Django
21:13
Daniel Roy Greenfeld
Рет қаралды 55 М.
Docker | Towards serving React (Nginx) with Django API (gunicorn)
48:35
Django API Authentication using JWT Tokens
37:06
Scalable Scripts
Рет қаралды 173 М.
I've been using Redis wrong this whole time...
20:53
Dreams of Code
Рет қаралды 340 М.
Heartwarming moment as priest rescues ceremony with kindness #shorts
00:33
Fabiosa Best Lifehacks
Рет қаралды 37 МЛН