Don't forget to check out my Complete Django Course! dub.sh/NvGboTI
@sontustripura31334 жыл бұрын
Someone : Do you have any Good Django book? Me: yes, I have the best one book.this is dennis Ivy. Just love you man!
@DennisIvy4 жыл бұрын
Haha thanks man! your awesome :)
@tanjimashraf8034 жыл бұрын
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.
@pulkittiwari98353 жыл бұрын
u have my deep respect bro.....i have seen about all the django lectures of youtube....none can be comparable with you...great work
@junecnol794 жыл бұрын
4:10 authentication check with python generator 10:02 authorization check with python nested generator 17:05 admin only authorization check
@ryan_03375 жыл бұрын
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
@DennisIvy5 жыл бұрын
Thank you Ryan! :)
@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.
@thexengengineer38704 жыл бұрын
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 !
@deadnetworksdead5963 жыл бұрын
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
@arthdave73134 жыл бұрын
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-bx5lg4 жыл бұрын
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.
@PGTechBar3 жыл бұрын
One of the best tutorials I have ever seen. The clean and simple way of demonstration.
@doniyorabduvokhidov17064 жыл бұрын
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!
@jessjoshi4 жыл бұрын
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.
@raparthipoornachanderrao51214 жыл бұрын
Thank you for giving this . I searched but like this video there is no other video.good explained.
@zoljargalenkhtaivan96613 жыл бұрын
All your projects are so great. Big thank from Mongolia
@UBLAunripped4 жыл бұрын
Dennis we REALLY appreciate all your hard work with these videos - we have gained SO much - thank you
@kate_chengdu4 жыл бұрын
your course is helping me with my project a lot. thank you!
@ShaunDePonte4 жыл бұрын
This app will work REALLY well if it's integrated into your e-commerce app as an admin/staff/management view
@loksewabyte5 жыл бұрын
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
@DennisIvy5 жыл бұрын
Thank you thank you thank you!!! :)
@loksewabyte5 жыл бұрын
@@DennisIvy Sir please upload Video On Django Rest Framework After completing this series
@mugumyavicent28033 жыл бұрын
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
@iajitpatil4 жыл бұрын
Your tutorial is awesome, it is really helping big time.. You almost taught entire Django for free !!!
@gulsabafiha15683 жыл бұрын
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!
@sundarali8454 жыл бұрын
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
@supritkumar26244 жыл бұрын
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
@yahialinus185110 ай бұрын
your content is pure diamond
@Shawn-tw3pg3 жыл бұрын
This lesson is very clear and detail, and it helps me a lots! Thank you very much : )
@sandrakuczynska34874 жыл бұрын
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?
@sandrakuczynska34874 жыл бұрын
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?
@mattclagett7784 жыл бұрын
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
@samuelairadion89914 жыл бұрын
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..
@ajithr12554 жыл бұрын
Add the following under the admin_only function in decorators.py: if group == 'customer': return HttpResponse('You are not authorised to view this page.')
@agungm62064 жыл бұрын
@@mattclagett778 thanks a lot man, you just save a day
@NOMOUSE2 жыл бұрын
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!
@valentinfontanger49624 жыл бұрын
I needed to find a way to shorten my code in my view and this is the perfect video ! Thank you !
@travistheall52604 жыл бұрын
I have been looking for a video like this for so long. Happy I found your channel man
@DennisIvy4 жыл бұрын
Glad this helped! Thank you so much for your feedback :)
@samarthgodase10114 жыл бұрын
The Best Django Tutorial Ever!
@machinimaaquinix31784 жыл бұрын
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.
@darren11074 жыл бұрын
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.
@migueljr61473 жыл бұрын
Hey dude, it was a amazing class! Thank y very much to share it! You have a giant knowledge with python/django.
@microtech51312 жыл бұрын
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..
@OlushiyanIbukunoluwa2 жыл бұрын
yo man, looking to work on a django project myself - care to connect to discuss?
@KingQAT4 жыл бұрын
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
@stagecoachmechanic4 жыл бұрын
I keep getting the same problem...
@ateebasif53604 жыл бұрын
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
@samuelairadion89914 жыл бұрын
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..
@chandrashekharsahani64824 жыл бұрын
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 .
@ajithr12554 жыл бұрын
Add the following under the admin_only function in decorators.py: if group == 'customer': return HttpResponse('You are not authorised to view this page.')
@alinandrei90064 жыл бұрын
I'm gratefull for these series.
@amitroth20114 жыл бұрын
How can i create the same implementation with CBV?
@nickrene Жыл бұрын
Thank you so much, this is a very helpful and great presentation by your side!
@muhammadibrahimnoor99154 жыл бұрын
HEY, what could be the ideal way to fix the problem you mentioned at 16:50? Thanks
@mohammedbasheeruddinbilal30704 жыл бұрын
One of the best Django tutorials!!
@ahmedbenyahia68534 жыл бұрын
Really thank you so much for sharing this tutorial, really great and opens so many horizon !!! Great work men
@amrelkholy6662 Жыл бұрын
one of the magic videos, you are really amazing
@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.
@saivenkantamanikanta4 жыл бұрын
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
@alfiandty4 жыл бұрын
me too bro
@nicholasvarela67114 жыл бұрын
same
@phucutube4 жыл бұрын
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.
@saivenkantamanikanta4 жыл бұрын
@@phucutube problem resolved and i forget to update the error bro
@machinimaaquinix31784 жыл бұрын
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.
@peronneaumoliere2874 жыл бұрын
I love you! you are an amazing teacher! You make me love Django!
@esequielalbornoz52714 жыл бұрын
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()
@esequielalbornoz52714 жыл бұрын
Also, remove the request parameter in the wrapper functions, to make them "usable" also in class base views
@pawanchhangani75284 жыл бұрын
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 Жыл бұрын
Thank You you saved my job today
@srich-k4 жыл бұрын
That was simple and brilliantly explained Thanks!
@serhiihoriaiev27674 жыл бұрын
Thanks for this super useful course! One remark: you shouldn't use mutable objects as default values to function parameters :) Привет из Украины!
@vikasjoshi4754 жыл бұрын
This is really helpful for me .Thanks man!
@debashisgupta27904 жыл бұрын
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
@valentinfontanger49624 жыл бұрын
docs.djangoproject.com/fr/3.0/topics/class-based-views/intro/. you have a section about how to do it for class based views
@lewiseman4 жыл бұрын
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
@Victornuamah12 жыл бұрын
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.
@wissemcherif29822 жыл бұрын
thanks a lot!!! so nice reverb
@osantos774 жыл бұрын
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?"
@DennisIvy4 жыл бұрын
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 :)
@rodrigosegura24004 жыл бұрын
Hi @@DennisIvy! Do you still plan to upload the Middleware video?
@aanchalsharma52644 жыл бұрын
def home(request): TypeError: 'NoneType' object is not callable i am stuck here for2 days please help
@dradrigapatrick4 жыл бұрын
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_bsnss74822 жыл бұрын
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?
@felixaponati43188 ай бұрын
Hello Dennis That's a great job Can you make a video on how to integrate formstack in Django
@ieanjeremiahgarcia87624 жыл бұрын
Thanks Dennis Ivy I learned a lot from you
@DennisIvy4 жыл бұрын
My pleasure :)
@ieanjeremiahgarcia87624 жыл бұрын
@@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.
@francismacho90284 жыл бұрын
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?
@sankarganeshinfotech4 жыл бұрын
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.16 ай бұрын
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
@gurnoorsinghdhanju26104 жыл бұрын
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
@valentinfontanger49624 жыл бұрын
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 Жыл бұрын
Thank you. It was really helpful.
@master-x72833 жыл бұрын
Great tutorial man!
@mdahanaf4 жыл бұрын
Many many Love For Your . I just love your tutorials . Salute you sir and thanks for bearing with us.
@DennisIvy4 жыл бұрын
It'y my privilege :)
@rahulkirar53615 жыл бұрын
Sir in dashboard update button isn't working.... Pls share the video
@DennisIvy5 жыл бұрын
What’s happening when you click it? Are you referring to the demo?
@rahulkirar53615 жыл бұрын
@@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
@DennisIvy5 жыл бұрын
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?
@rahulkirar53615 жыл бұрын
@@DennisIvy sir sorry i take my words back...you had make a video on it...but it's my mistake so sorry...
@DennisIvy5 жыл бұрын
Rahul I found the bug and fixed it in the source code. Thank you for pointing it out!
@technoinfoworldwide23295 жыл бұрын
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 ?
@DennisIvy5 жыл бұрын
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 :)
@kelvinkamau20334 жыл бұрын
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.
@rickinio4 жыл бұрын
Very well explained and thorough course. Thanks a lot! Have you got somewhere we can donate?
@minsukim68374 жыл бұрын
Thanks for the clear exlplanation ! This is what i want
@DennisIvy4 жыл бұрын
Your very welcome :)
@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-yu5yh3 жыл бұрын
AttributeError: 'User' object has no attribute 'group' ???????
@manojkumarn90273 жыл бұрын
Use groups
@k-webbs2 жыл бұрын
During registration, how do you ensure that you are checking if the user exists first before you create a new user?
@mikaeldoctore82003 жыл бұрын
what theme did you use in your sublime text editor?? thanks
@dennismillanzi14758 ай бұрын
Hello, iam getting an Attribute error which reads “NONE TYPE” object has no attribute “Groups” can you please help
@athulksuresh91643 жыл бұрын
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
@mohamnedgh52444 жыл бұрын
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 !
@valentinfontanger49624 жыл бұрын
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
@samyan76294 жыл бұрын
Thank you ,Dennis. i am your fans
@desmondabbah83723 жыл бұрын
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 Жыл бұрын
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.
@sumitthakur72164 жыл бұрын
ValueError: The view accounts.decorators.wrapper_function didn't return an HttpResponse object. It returned None instead.
@kyrierevival36584 жыл бұрын
what's your code inside decorator.py?
@sandrakuczynska34874 жыл бұрын
I have the same ValueError
@ladiffaerence24914 жыл бұрын
@@kyrierevival3658 I have the same problem
@KingQAT4 жыл бұрын
where u able to solve it?
@samuelairadion89914 жыл бұрын
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..
@sayliwangikar72433 жыл бұрын
Why are we passing the parameters *args and **kwargs in wrapper_func??
@mychromebook99353 жыл бұрын
when was the user.html file created ? Seems it just appeared out of thin air.
@PrimevalShrimp4 жыл бұрын
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 Жыл бұрын
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?
@marif51034 жыл бұрын
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
@TheLegendOfNiko4 жыл бұрын
How do you make it so that if a customer purchases a certain item, they are added to one of the allowed groups?
@Abh190214 жыл бұрын
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
@mugumyavicent28033 жыл бұрын
add another subscription link, i want to subscribe more that twice,,, hahahahaha ... you are the best. you have made my love Python.
@OpenThisGate873 жыл бұрын
Hello. How does the loginPage() function know what form to use? Thanks!
@letswatch2693 Жыл бұрын
in 'admin_only' what is 'user-page' exactly ? I put there my 'Home' page but site show me ERR_TOO_MANY_REDIRECTS
@nabinr.chaudhary99714 жыл бұрын
great explanation sir but how can i restricted user instance of is_staff
@thunder98094 жыл бұрын
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
@infernalpoetry1204 жыл бұрын
try with: group = Group.objects.get(name='customers')
@yeetergonzales8324 жыл бұрын
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
@sanjaymaharjan13234 жыл бұрын
this guys should have 1m subsribber
@diegovicuna10214 жыл бұрын
The way to do back space is holding shift and press tab
@petermulhall70054 жыл бұрын
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?