Well, I'm messing with an API and I want it to return the content only when the user sector is the same as the publishing sector.
Publications API:
The user has a sector field also equal to this, and I am already getting the id of the sector of the current user, but I can not get the sector id of the publication to test!
views.py
class PostDetailAPIView(RetrieveAPIView):
queryset = Post.objects.all()
serializer_class = PostSerializer
def get_queryset(self):
queryset = Post.objects.all()
user_sector = None
if self.request.user.is_authenticated():
user_sector = self.request.user.sector.id
if user_sector is ...:
return queryset
remembering that I want to return to queryset whenever the sector of some publication is equal to the sector of the logged in user !! help me on this