Skip to content
Advertisement

django-rest-framework – How to create seperate profiles for users based on is_staff

I am working on a job portal project. I am using custom user model

JavaScript

And I have 2 separate models one for job seekers and other for employers.

JavaScript

My doubt is how to restrict one user from creating a profile on other type of user based on is_staff field in User model.

I am new to django, please help me.

views.py

JavaScript

serializers.py

JavaScript

This allows employer to create seeker profile.

Advertisement

Answer

You would have to check the role of the authenticated user in your view and proceed accordingly – s.th. like

JavaScript
User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement