[Django]-How to allow only one User to see "UpdateView"?

4👍

It looks like you can override .get_object() method and include your own logic:

from django.shortcuts import get_object_or_404

class EditOrderView(UpdateView):
    model = Job
    ...

    def get_object(self, queryset=None):
        return get_object_or_404(self.model, pk=self.kwargs["pk"], customer=self.request.user)

Leave a comment