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

แชร์
ฝัง
  • เผยแพร่เมื่อ 5 ม.ค. 2025

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

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

    Don't forget to check out my Complete Django Course! dub.sh/NvGboTI

  • @sontustripura3133
    @sontustripura3133 4 ปีที่แล้ว +79

    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 ปีที่แล้ว +11

      Haha thanks man! your awesome :)

  • @tanjimashraf803
    @tanjimashraf803 4 ปีที่แล้ว +9

    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 ปีที่แล้ว +2

    u have my deep respect bro.....i have seen about all the django lectures of youtube....none can be comparable with you...great work

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

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

    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 ปีที่แล้ว +3

      Thank you Ryan! :)

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

    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.

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

    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 !

  • @ShivamSingh-bx5lg
    @ShivamSingh-bx5lg 4 ปีที่แล้ว +13

    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.

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

  • @PGTechBar
    @PGTechBar 3 ปีที่แล้ว

    One of the best tutorials I have ever seen. The clean and simple way of demonstration.

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

    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!

    • @yvyas9646
      @yvyas9646 11 วันที่ผ่านมา

      True though 😄

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

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

    4:10 authentication check with python generator
    10:02 authorization check with python nested generator
    17:05 admin only authorization check

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

    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

  • @loksewabyte
    @loksewabyte 5 ปีที่แล้ว

    You call it as a Django Crash course But its A really Corporate Level course . You are the best TH-camr ever in TH-cam 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

  • @UBLAunripped
    @UBLAunripped 4 ปีที่แล้ว

    Dennis we REALLY appreciate all your hard work with these videos - we have gained SO much - thank you

  • @iajitpatil
    @iajitpatil 4 ปีที่แล้ว

    Your tutorial is awesome, it is really helping big time.. You almost taught entire Django for free !!!

  • @gulsabafiha1568
    @gulsabafiha1568 4 ปีที่แล้ว

    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!

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

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

  • @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 ปีที่แล้ว +2

    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

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

    your course is helping me with my project a lot. thank you!

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

  • @travistheall5260
    @travistheall5260 4 ปีที่แล้ว

    I have been looking for a video like this for so long. Happy I found your channel man

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

      Glad this helped! Thank you so much for your feedback :)

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

    your content is pure diamond

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

    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.

  • @Shawn-tw3pg
    @Shawn-tw3pg 3 ปีที่แล้ว +1

    This lesson is very clear and detail, and it helps me a lots! Thank you very much : )

  • @valentinfontanger4962
    @valentinfontanger4962 4 ปีที่แล้ว

    I needed to find a way to shorten my code in my view and this is the perfect video ! Thank you !

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

    This app will work REALLY well if it's integrated into your e-commerce app as an admin/staff/management view

  • @migueljr6147
    @migueljr6147 4 ปีที่แล้ว

    Hey dude, it was a amazing class! Thank y very much to share it! You have a giant knowledge with python/django.

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

    The Best Django Tutorial Ever!

  • @mohammedbasheeruddinbilal3070
    @mohammedbasheeruddinbilal3070 4 ปีที่แล้ว

    One of the best Django tutorials!!

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

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

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

    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 ปีที่แล้ว +1

      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 ปีที่แล้ว +5

      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 ปีที่แล้ว +3

      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 ปีที่แล้ว +1

      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

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

    one of the magic videos, you are really amazing

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

    How can i create the same implementation with CBV?

  • @muhammadibrahimnoor9915
    @muhammadibrahimnoor9915 4 ปีที่แล้ว

    HEY, what could be the ideal way to fix the problem you mentioned at 16:50? Thanks

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

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

    I'm gratefull for these series.

  • @ahmedbenyahia6853
    @ahmedbenyahia6853 4 ปีที่แล้ว

    Really thank you so much for sharing this tutorial, really great and opens so many horizon !!!
    Great work men

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

    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 ปีที่แล้ว +1

      I keep getting the same problem...

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

      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 ปีที่แล้ว +1

      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 ปีที่แล้ว +1

      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.')

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

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

    Hi Dennis.
    Your are one of the best instructors I have found on TH-cam. 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.

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

    Thank you so much, this is a very helpful and great presentation by your side!

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

  • @peronneaumoliere287
    @peronneaumoliere287 4 ปีที่แล้ว

    I love you! you are an amazing teacher! You make me love Django!

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

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

    Hello, iam getting an Attribute error which reads “NONE TYPE” object has no attribute “Groups” can you please help

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

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

  • @betopolione.laura.gil.1
    @betopolione.laura.gil.1 7 หลายเดือนก่อน

    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

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

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

    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 ปีที่แล้ว +1

      me too bro

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

      same

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

      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.

  • @yohannesayana9456
    @yohannesayana9456 3 ปีที่แล้ว

    I followup all parts attentively and it works but i got the error in this part of the series....can u help me? the error says
    ValueError at /
    The view abiy.decorators.wrapper_function didn't return an HttpResponse object. It returned None instead.

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

    in 'admin_only' what is 'user-page' exactly ? I put there my 'Home' page but site show me ERR_TOO_MANY_REDIRECTS

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

  • @TrungNguyen-kt3lt
    @TrungNguyen-kt3lt 3 ปีที่แล้ว

    For superuser role, I couldn't get it to work. Seems like there's no group name 'admin'. So I add this: elif request.user.is_superuser:
    return view_func(request,*args,**kwargs)

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

    Thanks for this super useful course! One remark: you shouldn't use mutable objects as default values to function parameters :) Привет из Украины!

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

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

    Hello Dennis
    That's a great job
    Can you make a video on how to integrate formstack in Django

  • @HenryKamandeN
    @HenryKamandeN 4 ปีที่แล้ว

    'NoneType' object is not callable , site-packages/django/contrib/auth/decorators.py in _wrapped_view, line 21 return view_func(request, *args, **kwargs) , TypeError: 'NoneType' object is not callable How do i fix these ?

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

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

    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

  • @ahmadmubarak7744
    @ahmadmubarak7744 4 ปีที่แล้ว

    My full code is correct but there is one error (The view accounts.decorators.wrapper_func didn't return an HttpResponse object. It returned None instead) Please tell me why this error occurs

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

    can anyone resolve this

    Reverse for 'user-page' not found. 'user-page' is not a valid view function or pattern name

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

    Thank You you saved my job today

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

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

  • @diegovicuna1021
    @diegovicuna1021 4 ปีที่แล้ว

    The way to do back space is holding shift and press tab

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

  • @gouthamgondrala5273
    @gouthamgondrala5273 3 ปีที่แล้ว

    what if there are more than 2 groups how to assign then in the register page?

  • @OpenThisGate87
    @OpenThisGate87 3 ปีที่แล้ว

    Hello. How does the loginPage() function know what form to use? Thanks!

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

  • @shyamjaiswal8015
    @shyamjaiswal8015 4 ปีที่แล้ว

    How can I give permission to my emplyoees to view only few of my customer pages, this help would really be appriciated

  • @nabinr.chaudhary9971
    @nabinr.chaudhary9971 4 ปีที่แล้ว

    great explanation sir but how can i restricted user instance of is_staff

  • @mikaeldoctore8200
    @mikaeldoctore8200 3 ปีที่แล้ว

    what theme did you use in your sublime text editor?? thanks

  • @petermulhall7005
    @petermulhall7005 4 ปีที่แล้ว

    Hi, when my 'customer' logs in and gets redirected to the 'user' page there is no css formatting. Any ideas of what I could have done wrong? it was working up to the point of putting the @admin_only decorator in place.

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

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

    That was simple and brilliantly explained
    Thanks!

  • @preetham4974
    @preetham4974 4 ปีที่แล้ว

    def unauthenticated_user(view_function) takes the function and its arguments (i mean register(request) ) as view_function argument or just the request argument in the register function as view_function ? thank you

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

    def home(request):
    TypeError: 'NoneType' object is not callable
    i am stuck here for2 days
    please help

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

      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.

  • @akshaymhatre3669
    @akshaymhatre3669 3 ปีที่แล้ว

    How can we write test cases to test the allowed user decorator?

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

    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

  • @samyan7629
    @samyan7629 4 ปีที่แล้ว

    Thank you ,Dennis. i am your fans

  • @vikasjoshi475
    @vikasjoshi475 4 ปีที่แล้ว

    This is really helpful for me .Thanks man!

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

    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 ปีที่แล้ว +3

      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 ปีที่แล้ว +1

      Hi @@DennisIvy! Do you still plan to upload the Middleware video?

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

    thanks a lot!!! so nice reverb

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

    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 :)

  • @master-x7283
    @master-x7283 3 ปีที่แล้ว

    Great tutorial man!

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

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

  • @ShamsSarwari-m8g
    @ShamsSarwari-m8g ปีที่แล้ว

    Thank you. It was really helpful.

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

    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)

  • @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 ปีที่แล้ว +2

      It'y my privilege :)

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

    the source code link doesn´t work :( (at least for me)