User Role Based Permissions & Authentication | Django (3.0) Crash Course Tutorials (pt 15)

  Рет қаралды 293,763

Dennis Ivy

Dennis Ivy

Күн бұрын

Пікірлер: 299
@DennisIvy
@DennisIvy 5 ай бұрын
Don't forget to check out my Complete Django Course! dub.sh/NvGboTI
@sontustripura3133
@sontustripura3133 4 жыл бұрын
Someone : Do you have any Good Django book? Me: yes, I have the best one book.this is dennis Ivy. Just love you man!
@DennisIvy
@DennisIvy 4 жыл бұрын
Haha thanks man! your awesome :)
@tanjimashraf803
@tanjimashraf803 4 жыл бұрын
I have completed a beginner Django course, where I've learned the basic CRUD functionalities along with REST API CRUD with Angular 2. But as I'm doing this course, I've realized I missed many little things that matter. A big thanks to you, brother 💙 Love from Bangladesh.
@pulkittiwari9835
@pulkittiwari9835 3 жыл бұрын
u have my deep respect bro.....i have seen about all the django lectures of youtube....none can be comparable with you...great work
@junecnol79
@junecnol79 4 жыл бұрын
4:10 authentication check with python generator 10:02 authorization check with python nested generator 17:05 admin only authorization check
@ryan_0337
@ryan_0337 5 жыл бұрын
I discovered you since you start your channel and follow you is the best investment I made. You bring a lot of value with your expertise and put a lot of efforts to make clear explanation. I hope you will continue to put content in the future. Thank's for you work in this tutorial Dennis
@DennisIvy
@DennisIvy 5 жыл бұрын
Thank you Ryan! :)
@muhammadukkasha5048
@muhammadukkasha5048 Жыл бұрын
I ususally don't coment on any video but watching this playlist I would say that you are GEM man. Much appriciate to your efforts.
@thexengengineer3870
@thexengengineer3870 4 жыл бұрын
Hello Denny, I was searching for user login & login permission-based views in Django for a week until I landed on your tutorial. Tried a lot of tutorials, but not a single one covered things as profoundly as you did. Thanks a lot. Much love !
@deadnetworksdead596
@deadnetworksdead596 3 жыл бұрын
Great Video! One thing, for others that are watching, though. If you want to have multiple groups and your group, you are searching for, happens to be on any other than the first place of the array you wont get the results you want. Modifying the code as follows works for me: def allowed_roles(allowed_roles=[]): def decorator(view_func): def wrapper_func(request, *args, **kwargs): group = None if request.user.groups.exists(): for group in request.user.groups.all(): if group.name in allowed_roles: return view_func(request, *args, **kwargs) return HttpResponse('You are not authorized to view this page') return wrapper_func return decorator
@arthdave7313
@arthdave7313 4 жыл бұрын
Hey, man I am doing my MS in Computer Science, and I would definitely say that things I have learnt from this channel is way more valuable than what I have learnt at school. Thanks for sharing the knowledge. Just one suggestion. It would be great if you can keep some exercise after the completion of the topics you cover in the video.
@ShivamSingh-bx5lg
@ShivamSingh-bx5lg 4 жыл бұрын
Dude, you are simply great. Please do an In-depth DRF tutorial and combine it with React, as there are not many tutorials on DRF available.
@PGTechBar
@PGTechBar 3 жыл бұрын
One of the best tutorials I have ever seen. The clean and simple way of demonstration.
@doniyorabduvokhidov1706
@doniyorabduvokhidov1706 4 жыл бұрын
Previous tutorials were somehow easy but this one is a real pain. Have to watch and analyze couple of times. BTW, i want to say tons of thanks for u for this amazing content!
@jessjoshi
@jessjoshi 4 жыл бұрын
you are jut amazing .. I tried to learn django last year . but no luck .. but this month I found you .. and everything just making sense and not hard at all.
@raparthipoornachanderrao5121
@raparthipoornachanderrao5121 4 жыл бұрын
Thank you for giving this . I searched but like this video there is no other video.good explained.
@zoljargalenkhtaivan9661
@zoljargalenkhtaivan9661 3 жыл бұрын
All your projects are so great. Big thank from Mongolia
@UBLAunripped
@UBLAunripped 4 жыл бұрын
Dennis we REALLY appreciate all your hard work with these videos - we have gained SO much - thank you
@kate_chengdu
@kate_chengdu 4 жыл бұрын
your course is helping me with my project a lot. thank you!
@ShaunDePonte
@ShaunDePonte 4 жыл бұрын
This app will work REALLY well if it's integrated into your e-commerce app as an admin/staff/management view
@loksewabyte
@loksewabyte 5 жыл бұрын
You call it as a Django Crash course But its A really Corporate Level course . You are the best KZbinr ever in KZbin in context of Django tutorials.Thank you a lot For such powerful Content. Please upload more video on django advanced topics like djnago signals, Resst Framework and more
@DennisIvy
@DennisIvy 5 жыл бұрын
Thank you thank you thank you!!! :)
@loksewabyte
@loksewabyte 5 жыл бұрын
@@DennisIvy Sir please upload Video On Django Rest Framework After completing this series
@mugumyavicent2803
@mugumyavicent2803 3 жыл бұрын
i have followed your videos, they are nice,,, thanks for teaching the entire world, you deserve some tea from me. May you keep blessed ... ever
@iajitpatil
@iajitpatil 4 жыл бұрын
Your tutorial is awesome, it is really helping big time.. You almost taught entire Django for free !!!
@gulsabafiha1568
@gulsabafiha1568 3 жыл бұрын
Thank you very much Dennis. It's really very salutatory for us and for those who want to learn django with the best outcome. much love for you man!
@sundarali845
@sundarali845 4 жыл бұрын
This one was a little bit complicated but i think i couldnt have found better explanation else where...Love u course..been following this series from part 1
@supritkumar2624
@supritkumar2624 4 жыл бұрын
Thank you very much for all your great lession through this course .It cleared some of the doubts previously i had.This course will be helpful after many decades also . M from India #Support you
@yahialinus1851
@yahialinus1851 10 ай бұрын
your content is pure diamond
@Shawn-tw3pg
@Shawn-tw3pg 3 жыл бұрын
This lesson is very clear and detail, and it helps me a lots! Thank you very much : )
@sandrakuczynska3487
@sandrakuczynska3487 4 жыл бұрын
Dennis, thank you for this tutorial. It's great. But I have a problem with the decorator @allowed_users. I'm getting this error: Exception Type: ValueError Exception Value: The view accounts.decorators.wrapper_function didn't return an HttpResponse object. It returned None instead. Can you help me?
@sandrakuczynska3487
@sandrakuczynska3487 4 жыл бұрын
I think that something is wrong in db (while creating a user), because when you logged into admin panel and hit "Home › Authentication and Authorization › Users › Dennis" - then you have "Groups" field and there is a "customer" and in the field "Chosen groups" you have "admin", unlike you, when I hit my admin's name, I don't have Groups it in this place , I have an empty field. That's why the decorator doesn't work. How can I fix that?
@mattclagett778
@mattclagett778 4 жыл бұрын
I fixed this issue - I was logged into a user that did not have admin privileges. Went into DB and gave admin and now it works
@samuelairadion8991
@samuelairadion8991 4 жыл бұрын
simple..when creating your Group at your admin page. make sure the group names eg admin, customer is exactly the same with the string 'admin' and 'customer'. at your decorators.py file.this causes the error..like in my case i missplelled mine as Admin and Customers..
@ajithr1255
@ajithr1255 4 жыл бұрын
Add the following under the admin_only function in decorators.py: if group == 'customer': return HttpResponse('You are not authorised to view this page.')
@agungm6206
@agungm6206 4 жыл бұрын
@@mattclagett778 thanks a lot man, you just save a day
@NOMOUSE
@NOMOUSE 2 жыл бұрын
Dude, I don't speak English but I love to learn these things... you are fantastic! Thank you so. I just couldn't get vscode to recognize decorators as a module, so I inserted my decorations into views, py anyway. Cheers!
@valentinfontanger4962
@valentinfontanger4962 4 жыл бұрын
I needed to find a way to shorten my code in my view and this is the perfect video ! Thank you !
@travistheall5260
@travistheall5260 4 жыл бұрын
I have been looking for a video like this for so long. Happy I found your channel man
@DennisIvy
@DennisIvy 4 жыл бұрын
Glad this helped! Thank you so much for your feedback :)
@samarthgodase1011
@samarthgodase1011 4 жыл бұрын
The Best Django Tutorial Ever!
@machinimaaquinix3178
@machinimaaquinix3178 4 жыл бұрын
For those following this tute and getting misc errors - be sure you are consistent in the usage of capitalization in the code files with the group names you created in the Django admin site. This will solve most errors.
@darren1107
@darren1107 4 жыл бұрын
Love this tutorial. I would love to see you turn this into a backend api with django rest framework and handle the front with Vue or React! I've completed most of your videos working along, super helpful. Well done.
@migueljr6147
@migueljr6147 3 жыл бұрын
Hey dude, it was a amazing class! Thank y very much to share it! You have a giant knowledge with python/django.
@microtech5131
@microtech5131 2 жыл бұрын
Massive Respect Broo....Really appreciate for the nice content you upload for....Am doing a python / Django project and most of your content has helped me solve a few problems here and there and also taught me things i dint know how to solve..
@OlushiyanIbukunoluwa
@OlushiyanIbukunoluwa 2 жыл бұрын
yo man, looking to work on a django project myself - care to connect to discuss?
@KingQAT
@KingQAT 4 жыл бұрын
I keep getting this error "ValueError: The view accounts.decorators.wrapper_function didn't return an HttpResponse object. It returned None instead." any clue how to solve it, my code wasnt doing it properly so i copy pasted the source code and lined it up with mine
@stagecoachmechanic
@stagecoachmechanic 4 жыл бұрын
I keep getting the same problem...
@ateebasif5360
@ateebasif5360 4 жыл бұрын
else: # return HttpResponse('you are not authorized to view this page') return redirect('user-page') use this in else tag comment out or remove the HttpRespnse and write just return redirect('user-page') and in the views.py use allowed_user decorator instead of admin only your error will be removed
@samuelairadion8991
@samuelairadion8991 4 жыл бұрын
simple..when creating your Group at your admin page. make sure the group names eg admin, customer is exactly the same with the string 'admin' and 'customer'. at your decorators.py file.this causes the error..like in my case i missplelled mine as Admin and Customers..
@chandrashekharsahani6482
@chandrashekharsahani6482 4 жыл бұрын
when you change the permission from admin panel like ' user1 to admin and user2 to customer you forgot to press save button ' so click on save. it will work .
@ajithr1255
@ajithr1255 4 жыл бұрын
Add the following under the admin_only function in decorators.py: if group == 'customer': return HttpResponse('You are not authorised to view this page.')
@alinandrei9006
@alinandrei9006 4 жыл бұрын
I'm gratefull for these series.
@amitroth2011
@amitroth2011 4 жыл бұрын
How can i create the same implementation with CBV?
@nickrene
@nickrene Жыл бұрын
Thank you so much, this is a very helpful and great presentation by your side!
@muhammadibrahimnoor9915
@muhammadibrahimnoor9915 4 жыл бұрын
HEY, what could be the ideal way to fix the problem you mentioned at 16:50? Thanks
@mohammedbasheeruddinbilal3070
@mohammedbasheeruddinbilal3070 4 жыл бұрын
One of the best Django tutorials!!
@ahmedbenyahia6853
@ahmedbenyahia6853 4 жыл бұрын
Really thank you so much for sharing this tutorial, really great and opens so many horizon !!! Great work men
@amrelkholy6662
@amrelkholy6662 Жыл бұрын
one of the magic videos, you are really amazing
@gebreajax3227
@gebreajax3227 Жыл бұрын
I have completed your crash course, and it helps me a lot, thank you so much. If You have a react crash course please put the links here.
@saivenkantamanikanta
@saivenkantamanikanta 4 жыл бұрын
While I had done this in the admin only function I am getting the error as "cannot return the decorator so none object returned". Can u please rectify this error bro
@alfiandty
@alfiandty 4 жыл бұрын
me too bro
@nicholasvarela6711
@nicholasvarela6711 4 жыл бұрын
same
@phucutube
@phucutube 4 жыл бұрын
I was receiving this error as well. I suggest you go into your admin panel and make sure your user has the customer group assigned. I had mine assigned, but not saved. Also make sure your spelling is the same across the board.
@saivenkantamanikanta
@saivenkantamanikanta 4 жыл бұрын
@@phucutube problem resolved and i forget to update the error bro
@machinimaaquinix3178
@machinimaaquinix3178 4 жыл бұрын
To clarify - be sure you keep the proper capitalization. In Dennis' code, admin and customer are lower case. If your groups begin with capital letters like so: "Admin" and "Customer" then you will get the error in the OP.
@peronneaumoliere287
@peronneaumoliere287 4 жыл бұрын
I love you! you are an amazing teacher! You make me love Django!
@esequielalbornoz5271
@esequielalbornoz5271 4 жыл бұрын
Hey there! Really like video! But i suggest everyone not to use allowed_roles=[] (10:30) instead use allowed_roles=None and within the function: if allowed_roles is None: allowed_roles=list()
@esequielalbornoz5271
@esequielalbornoz5271 4 жыл бұрын
Also, remove the request parameter in the wrapper functions, to make them "usable" also in class base views
@pawanchhangani7528
@pawanchhangani7528 4 жыл бұрын
allowed roles basically why we use to it. Only we have to check whether a user is superuser or not for that we can use if request.user.is_superuser: he will be able to see the view otherwise not
@platov267
@platov267 Жыл бұрын
Thank You you saved my job today
@srich-k
@srich-k 4 жыл бұрын
That was simple and brilliantly explained Thanks!
@serhiihoriaiev2767
@serhiihoriaiev2767 4 жыл бұрын
Thanks for this super useful course! One remark: you shouldn't use mutable objects as default values to function parameters :) Привет из Украины!
@vikasjoshi475
@vikasjoshi475 4 жыл бұрын
This is really helpful for me .Thanks man!
@debashisgupta2790
@debashisgupta2790 4 жыл бұрын
how can i use this allowed_user decorator for classbased view. View_func works for function . it doesn't work for classbased view. please help me
@valentinfontanger4962
@valentinfontanger4962 4 жыл бұрын
docs.djangoproject.com/fr/3.0/topics/class-based-views/intro/. you have a section about how to do it for class based views
@lewiseman
@lewiseman 4 жыл бұрын
love your work :) Also note if you try to log in with the superuser account after adding the @admin_only decorator you will receive an error since its not in the groups specified
@Victornuamah1
@Victornuamah1 2 жыл бұрын
Hi Dennis. Your are one of the best instructors I have found on KZbin. Your 7 hours django crash course and this customer management course have helped me a lot in my django learning pathway. Base on the information I have attained from those courses, I have started a Church Management System but I want to allow members where necessary, to have multiple user roles incase they are serving in more than one departments. My problem is which page will they see after login to the system? Please help me Dennis, I really need help on this.
@wissemcherif2982
@wissemcherif2982 2 жыл бұрын
thanks a lot!!! so nice reverb
@osantos77
@osantos77 4 жыл бұрын
Hi, Thank you for the awesome content! I have a question "what is the difference between using decorator and middleware in Django when applying roles and permission?"
@DennisIvy
@DennisIvy 4 жыл бұрын
Just different ways to accomplish the same task. I personally prefer middleware because we can create all logic in one area rather than having to add a decorator over each view. I'll be putting something together on middleware in the future :)
@rodrigosegura2400
@rodrigosegura2400 4 жыл бұрын
Hi @@DennisIvy! Do you still plan to upload the Middleware video?
@aanchalsharma5264
@aanchalsharma5264 4 жыл бұрын
def home(request): TypeError: 'NoneType' object is not callable i am stuck here for2 days please help
@dradrigapatrick
@dradrigapatrick 4 жыл бұрын
I ran into same problem too but i found the problem being with my naming convention. The names i called in the decorators wasnt matching the one set in the url.py Maybe you check their.
@franco_bsnss7482
@franco_bsnss7482 2 жыл бұрын
Dennis thanks for sharing your knowledge with us. After ending this course, which level would I have? Could I be able to make a simple website?
@felixaponati4318
@felixaponati4318 8 ай бұрын
Hello Dennis That's a great job Can you make a video on how to integrate formstack in Django
@ieanjeremiahgarcia8762
@ieanjeremiahgarcia8762 4 жыл бұрын
Thanks Dennis Ivy I learned a lot from you
@DennisIvy
@DennisIvy 4 жыл бұрын
My pleasure :)
@ieanjeremiahgarcia8762
@ieanjeremiahgarcia8762 4 жыл бұрын
@@DennisIvy Sir I know This is too much but I just want to ask if how can I create an order using the user page I'm having a hard time to come up with some solution so I take a chance to ask you about it, it bothers me for almost a month. I hope you can help me sir and advance Thank you and God Bless you, Sir.
@francismacho9028
@francismacho9028 4 жыл бұрын
Dennis, thanks for this course. My question though is how do I iterate to check groups when user belongs to more than 1 group? I have a supervisor group, admin and sales staff group and a user can belong to supervisor and admin group. how do I iterate through without indexing the group manually?
@sankarganeshinfotech
@sankarganeshinfotech 4 жыл бұрын
incase if the user belongs to multiple groups just use the below code. def allowed_users(allowed_roles=[]): def decorator(view_func): def wrapper_func(request, *args, **kwargs): group = None groups_list = [] if request.user.groups.exists(): for group in request.user.groups.all(): groups_list.append(group.name) # group = request.user.groups.all()[0].name if any(group in groups_list for group in allowed_roles): # if group in allowed_roles: return view_func(request, *args, **kwargs) else: return HttpResponse('You are not authorized to view this page') return wrapper_func return decorator
@betopolione.laura.gil.1
@betopolione.laura.gil.1 6 ай бұрын
hey man, I love your videos, you are amaizng. Just a little unrelated question, I saw that some times you use camelCase for name funcions, and some times you use snake_case. Is there a reason for that? When should I use one or another? thanks
@gurnoorsinghdhanju2610
@gurnoorsinghdhanju2610 4 жыл бұрын
Hey dennis i have a query regarding import export model in django admin ....how to export foreign key attributes rather than the number of foreign key
@valentinfontanger4962
@valentinfontanger4962 4 жыл бұрын
first thing that comes to my mind : 1) retrieve the instance 2 ) now you have the id, you can just retrieve the instance you want based on this id with : X.objects.get(id=the_id_your_got)
@ShamsSarwari-m8g
@ShamsSarwari-m8g Жыл бұрын
Thank you. It was really helpful.
@master-x7283
@master-x7283 3 жыл бұрын
Great tutorial man!
@mdahanaf
@mdahanaf 4 жыл бұрын
Many many Love For Your . I just love your tutorials . Salute you sir and thanks for bearing with us.
@DennisIvy
@DennisIvy 4 жыл бұрын
It'y my privilege :)
@rahulkirar5361
@rahulkirar5361 5 жыл бұрын
Sir in dashboard update button isn't working.... Pls share the video
@DennisIvy
@DennisIvy 5 жыл бұрын
What’s happening when you click it? Are you referring to the demo?
@rahulkirar5361
@rahulkirar5361 5 жыл бұрын
@@DennisIvy yes I also download the code from git... But in order html their are some functionality you add but u don't make a video on it
@DennisIvy
@DennisIvy 5 жыл бұрын
Ah yes, there were a few corrections I made that I’m gonna make videos on to get everyone up to speed. Wich link did you download from? More specifically Wich video number?
@rahulkirar5361
@rahulkirar5361 5 жыл бұрын
@@DennisIvy sir sorry i take my words back...you had make a video on it...but it's my mistake so sorry...
@DennisIvy
@DennisIvy 5 жыл бұрын
Rahul I found the bug and fixed it in the source code. Thank you for pointing it out!
@technoinfoworldwide2329
@technoinfoworldwide2329 5 жыл бұрын
django.contrib.auth.decorators import login_required @login_required(login_url='login') I had use same to same your code but it doesnt work for me ,can you please help me? is it because i havent put logout option?it is necesary to work for logout option and then these above functionality works ?
@DennisIvy
@DennisIvy 5 жыл бұрын
Yes if you haven't worked with the decorators then just go ahead and remove them because it will cause an error. If your still having issues send me your views.py file or just a screenshot to dennisivy11@gmail.com and I'll take a look :)
@kelvinkamau2033
@kelvinkamau2033 4 жыл бұрын
Hi, great course Dennis. I have a question. Lets say You want to create a user and you want to associate the user with a specific group i.e Admin, Seller and Customer. I dont need the user to always be a customer like in the below code. group = Group.objects.get(name='Customer') user.groups.add(group) Is there a way i could select which group i want my user to belong to? i.e Like a dropdown which i could select the group.
@rickinio
@rickinio 4 жыл бұрын
Very well explained and thorough course. Thanks a lot! Have you got somewhere we can donate?
@minsukim6837
@minsukim6837 4 жыл бұрын
Thanks for the clear exlplanation ! This is what i want
@DennisIvy
@DennisIvy 4 жыл бұрын
Your very welcome :)
@appiah-kubifrank7378
@appiah-kubifrank7378 Жыл бұрын
Hi am a beginner and am facing difficulties, please is it possible to purchase your source code and videos? so that i can study offline? thank you
@GeanCarlos-yu5yh
@GeanCarlos-yu5yh 3 жыл бұрын
AttributeError: 'User' object has no attribute 'group' ???????
@manojkumarn9027
@manojkumarn9027 3 жыл бұрын
Use groups
@k-webbs
@k-webbs 2 жыл бұрын
During registration, how do you ensure that you are checking if the user exists first before you create a new user?
@mikaeldoctore8200
@mikaeldoctore8200 3 жыл бұрын
what theme did you use in your sublime text editor?? thanks
@dennismillanzi1475
@dennismillanzi1475 8 ай бұрын
Hello, iam getting an Attribute error which reads “NONE TYPE” object has no attribute “Groups” can you please help
@athulksuresh9164
@athulksuresh9164 3 жыл бұрын
when I click on logout and then back button from the browser it shows me the home page. user type is not anonymous what to do
@mohamnedgh5244
@mohamnedgh5244 4 жыл бұрын
Mu friend i hope u see it , i keep getting this error , after having added admin_only decorator and then go to login page and then i just try to go to ma main page without log in and it says anonymous user !
@valentinfontanger4962
@valentinfontanger4962 4 жыл бұрын
It means that your user is not authenticated anymore. Because you are setting the admin_only, you don't have access to the main page because your user is not authenticated. This is what I think at least
@samyan7629
@samyan7629 4 жыл бұрын
Thank you ,Dennis. i am your fans
@desmondabbah8372
@desmondabbah8372 3 жыл бұрын
Hello Dennis, please can you do a video for me on how to have email verification before allowing the user to login with the UserCreationForm and also do how to login with email instead of the username please. Thanks and really love your works
@ErWasiKhan
@ErWasiKhan Жыл бұрын
There is one problem, If admin adding new group. So I think the new group will not work. We do not want to modify the code at server level. Please suggest. I tried but failed. I think The route should fetch current user role/group then compare with the view function. Request you to please give solution. I stucked in this problem. Thanks in advance.
@sumitthakur7216
@sumitthakur7216 4 жыл бұрын
ValueError: The view accounts.decorators.wrapper_function didn't return an HttpResponse object. It returned None instead.
@kyrierevival3658
@kyrierevival3658 4 жыл бұрын
what's your code inside decorator.py?
@sandrakuczynska3487
@sandrakuczynska3487 4 жыл бұрын
I have the same ValueError
@ladiffaerence2491
@ladiffaerence2491 4 жыл бұрын
@@kyrierevival3658 I have the same problem
@KingQAT
@KingQAT 4 жыл бұрын
where u able to solve it?
@samuelairadion8991
@samuelairadion8991 4 жыл бұрын
simple..when creating your Group at your admin page. make sure the group names eg admin, customer is exactly the same with the string 'admin' and 'customer'. at your decorators.py file.this causes the error..like in my case i missplelled mine as Admin and Customers..
@sayliwangikar7243
@sayliwangikar7243 3 жыл бұрын
Why are we passing the parameters *args and **kwargs in wrapper_func??
@mychromebook9935
@mychromebook9935 3 жыл бұрын
when was the user.html file created ? Seems it just appeared out of thin air.
@PrimevalShrimp
@PrimevalShrimp 4 жыл бұрын
To check if any of the users groups matches any of the allowed roles just use this code. Upvote so that others can see it! :) if request.user.groups.exists(): groups = [e.name for e in request.user.groups.all()] # check if intersection of allowed roles and groups if set(allowed_roles).intersection(set(groups)): return view_func(request, *args, **kwargs) return HttpResponse("You are not authorized to view this page")
@BensonIbe
@BensonIbe Жыл бұрын
instead of return the Http response, I just return render the user page. so if you are not allowed to be there, it redirects your to where your should be. like this def allowed_users(allowed_roles=[]): def decorator(view_func): def wrapper_func(request, *args, **kwargs): group = None if request.user.groups.exists(): group = request.user.groups.all()[0].name if group in allowed_roles: return view_func(request, *args, **kwargs) else: return render(request, 'accounts/user.html') return wrapper_func return decorator see the else statement. is theis logic okay?
@marif5103
@marif5103 4 жыл бұрын
This content is awesome and so well explained Dennis. Have one question though , I want to set the permissions of a few admin panel users so that , they can only view the data and not be able to change it, could you show how to do that
@TheLegendOfNiko
@TheLegendOfNiko 4 жыл бұрын
How do you make it so that if a customer purchases a certain item, they are added to one of the allowed groups?
@Abh19021
@Abh19021 4 жыл бұрын
Hi Dennis, I have a question. I have a simple blog and I want a user(suppose it's John) who has access to add new posts to only view his own posts and when he adds a new blog post from the admin, he should only be able to select his name as an author. How can I restrict this user to only select his name as the author and can only see his own posts? Thanks a lot
@mugumyavicent2803
@mugumyavicent2803 3 жыл бұрын
add another subscription link, i want to subscribe more that twice,,, hahahahaha ... you are the best. you have made my love Python.
@OpenThisGate87
@OpenThisGate87 3 жыл бұрын
Hello. How does the loginPage() function know what form to use? Thanks!
@letswatch2693
@letswatch2693 Жыл бұрын
in 'admin_only' what is 'user-page' exactly ? I put there my 'Home' page but site show me ERR_TOO_MANY_REDIRECTS
@nabinr.chaudhary9971
@nabinr.chaudhary9971 4 жыл бұрын
great explanation sir but how can i restricted user instance of is_staff
@thunder9809
@thunder9809 4 жыл бұрын
hello sir please help, when i add this code in registor_user view.py : group = Group.objects.get(name='customer') user.groups.add(group) and then registor new user , and try to login its give this error
@infernalpoetry120
@infernalpoetry120 4 жыл бұрын
try with: group = Group.objects.get(name='customers')
@yeetergonzales832
@yeetergonzales832 4 жыл бұрын
I had problem with ValueError at / The view accounts.decorators.wrapper_function didn't return an HttpResponse object. It returned None instead - and then I realized that my "admin" user was not added in admin group so I just added him in and all worked. So users added be4 this tutorial are not in any group. Hope it helped
@sanjaymaharjan1323
@sanjaymaharjan1323 4 жыл бұрын
this guys should have 1m subsribber
@diegovicuna1021
@diegovicuna1021 4 жыл бұрын
The way to do back space is holding shift and press tab
@petermulhall7005
@petermulhall7005 4 жыл бұрын
For some reason now all my tags are showing up as hyperlinks and forcing me to the login page. Weird. Any ideas how I might rectify this? Also the section on the dashboard page that list the last 5 orders is now below the customers section. Can anyone suggest a fix for these?
coco在求救? #小丑 #天使 #shorts
00:29
好人小丑
Рет қаралды 120 МЛН
To Brawl AND BEYOND!
00:51
Brawl Stars
Рет қаралды 17 МЛН
СИНИЙ ИНЕЙ УЖЕ ВЫШЕЛ!❄️
01:01
DO$HIK
Рет қаралды 3,3 МЛН
Password Reset Email | Django (3.0) Crash Course Tutorials (pt 20)
19:28
Session Vs JWT: The Differences You May Not Know!
7:00
ByteByteGo
Рет қаралды 290 М.
NestJs RBAC - Role Based Authorization Tutorial
24:35
Code with Vlad
Рет қаралды 26 М.
Django developers love HTMX
12:55
Dennis Ivy
Рет қаралды 6 М.
Learn Django - Class-Based Permission Checks
27:09
Very Academy
Рет қаралды 26 М.
Google’s Quantum Chip: Did We Just Tap Into Parallel Universes?
9:34
Role-Based Authentication in React (Complete Tutorial)
26:31
Cosden Solutions
Рет қаралды 37 М.
Multiple User Types | Django
21:13
Daniel Roy Greenfeld
Рет қаралды 57 М.
coco在求救? #小丑 #天使 #shorts
00:29
好人小丑
Рет қаралды 120 МЛН