0

I am new to django and am working on a django project, where I want to show/hide menus in accordance with the permissions a logged in user has. I am using Django Rest Framework and JWT. I did not find any url in rest_auth.urls to fetch all the permissions logged in user has. Can you please help me, how would you go about it ?

Ketan Shukla
  • 93
  • 1
  • 5
  • If you're using DRF presumably with an SPA, how would Django even be responsible fro drawing menus? – Ken Kinder Mar 01 '20 at 09:12
  • Django isn't going to draw menus but UI designers require permissions a logged in user has in order to show only relevant menus. For them to be able to do that, I need to provide them an endpoint so they have that information as soon as user log in. – Ketan Shukla Mar 01 '20 at 09:22
  • You'll probably need to create an endpoint that tells the UI what permissions it does and doesn't have then. Or perhaps an endpoint that tells the UI what actions the end-user can perform. That isn't something that's built into REST, Django, or Django Rest Framework and there's no standard way to do it. – Ken Kinder Mar 01 '20 at 10:33

1 Answers1

0

Your UI should not go through the permissions itself. Instead, it should send a request to the backend, and in a Django View you can check the permission and send a response to the UI.

Cedric Druck
  • 1,032
  • 7
  • 20
  • There are multiple models in the project and as many menus in the UI for CRUD. Management wants me to show only relevant menus to the user being logged in to reduce the clutter. – Ketan Shukla Mar 01 '20 at 09:18