User Pages based on Permissions | Django Inventory Management System Web Application
ฝัง
- เผยแพร่เมื่อ 28 ต.ค. 2024
- In this video, we will look at User Pages based on Permissions. We will learn how to build user specific pages that must be rendered for a logged in user based on permissions the user is assigned to. By so doing, an Admin and a User will have a different pages for their index page page. The source code to the project is in the link below. Also the code for the templates are included
Project Source Code:
github.com/Ken...
Dashboard Interface Design Source Code:
github.com/Ken...
Follow me on:
Twitter: / kenbroni
Facebook: / kenneth.broni.9
Python Official website:
www.python.org...
Download and Install Python on Windows 10 Computer
• Download and Install P...
Python Programming | Series Tutorial
• Python Programming | S...
Bootstrap4.5 Series Tutorial
• Bootstrap 4.5 | Series...
#InventoryManagementSystem
#Python
#Django
One of the best thing of this guy is you can replicate every single step without problems, this encourage you to continue, Thanks Ken.
Sir, You should be proud of yourself. I've been looking for the user different permissions for two days long and I haven't found the right one until you.
Another fantastic video, brother! Loving the series!
I have a question though (I'm about to go look at the docs).. The logic for the admin/staff bit seems like it shouldn't work but it does.. For example, I read "if user.is_authenticated and user.is_staff and user.is_superuser"
as
"if the user is authenticaed, and if they are staff, and if they are superuser"... Which would mean they have to be all 3 of these.
Else
"if they're not these three, show them this page 'dashboard/staff_index.html' ".
In my mind, if you logged in as staff, the if statement should fail because you;re not superuser, only staff... But it somehow works out that you;re staff and gives you the staff page.
In my mind it should be more like:
"if user is authenticated and is staff" shows staff page
"if user is authenticated and is superuser" show admin page
"else" show.. some kind of access denied page or something.
I don't understand how this if statement is able to still run when all 3 conditions are not met and then show the staff page under the "else" clause.. I'm not sure you'll be able to explain this in the space of a comment here but maybe you could link me to some docs or somewhere that I can get my head around it?
Thanks again for the awesome videos!
the reason why it works is because if user.is_superuser is True, then the rest will be true (Because of the hierarchy, super_user > Staff).
@@nhuong360 Ah I see! Thanks for the info :)
Thank you, very nice tutorial. I figured we can also redirect unauthorized users in the view method instead like this:
user = User.objects.get(username=request.user)
if not user.is_staff:
return HttpResponseRedirect('/logout')
else: render(...)
Thank you brother, for excellent tutorial!
thanks for the content.it contributed to my final year project. Keep up the good work.
I wish you uploaded the products with their images...
Great ... thanks for putting out great content
very informative and useful, thanks.
This is wonderful
What's the difference between login_required and Loginrequiredmixing? or is just diferent approach for the same thing?
The login_required decorators are used on function based views while the Mixins are used for class based views. However, they serve the same purpose.
Hi brother, How are you ?
I'd like to thank you for this simple video about handling user permissions, you just mad it so simple and easy , but accept this from me please , if u want ppl to learn don't copy and past staff such as frontend please do every thin from scratch and ur font size little big.
please let me know how I can send money for you m8. thanks a lot 10/10.
he did everything from scratch, check out his frontend video of this project
Django - login_required not redirecting in chrom but it works in edge why it so I have also tried to clear cache from the browser
my login_requrired is not working after applying login url also still it's accessible through the url's directly.
Awesome 😎
Hie fam. I seem to have encountered a "You are not authorized to view this page" message on the admin dashboard.
Kindly check the permissions. In the work, I have a couple of Users of whom 1 is an Admin. The Admin is the one I created as a superuser from the terminal. It is only the User with super user status that can view the admin dashboard.
@@KenBroTech when i created my superuser i assigned all permissions so when im on the dashboard i can add products but i cannot delete and edit. Thats where the error is. For the staff dashboard everythng is fine
@@4uxion Do a makemigration and then migrate. I'm sure some of the models haven't related well
@@KenBroTech i figured it out. I had made a mistake with my view for authorized user function... Also forgot to makemigrations. Thanks a lot man. Much love for your channel. Good day
I get sad every time the video ends :D
Thanks
Great !
Log in with Godfred next time