Ограничение доступа для каждого клиента в django

Я пытаюсь ограничить доступ к записям на основе каждого клиента, чтобы пользователи не могли получить доступ к данным друг друга через URL. Я добавил это, но он ограничивает все. Пожалуйста, помогите.

if request.user.customer != Infringement.customer: return HttpResponse('Your are not allowed here!!!')"

.

views.py

   @login_required(login_url='login') 
   def infringement(request, pk):   
      if request.user.customer != Infringement.customer:
       return HttpResponse('Your are not allowed here!!')
   infringement = Infringement.objects.get(id=pk)    
   notes = infringement.note_set.all().order_by('-created')
     if request.method == "POST":
      note = Note.objects.create(
      customer=request.user.customer,
      user = request.user,
      infringement = infringement,
      body=request.POST.get('body')
  )    
  return redirect('infringement', pk=infringement.id)

context= {'infringement': infringement, 'notes': notes}    return
render(request, 'base/infringements.html', context)

Попытка:

@login_required(login_url='login') 
def infringement(request, pk):   
      infringement = Infringement.objects.get(id=pk)
      if request.user.customer.id != infringement.customer.id:
          return HttpResponse('Your are not allowed here!!')
Вернуться на верх