1👍
✅
Try:
@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!!')
Source:stackexchange.com