I am trying to restrict instances of an object to be viewable only to users referenced by that object via a OneToOneField. I’m using the “user\_passes\_test” mixin on a DetailView to compare request.user to the user in the OnetoOne relationship. I got some help on django irc which led me to unsuccessfully try and implement get\_object, but I’m still stuck (I'm new to Django & Python).

**the Model:**

```
class Event(models.Model):     
    client = models.OneToOneField(settings.AUTH_USER_MODEL)

```

**the View:**

```
class EventDetail(UserPassesTestMixin, DetailView):
    model = Event

    def test_func(self):
        if self.request.user == self.model.client:
            return True
        else:
            return False

```

*User is being referenced in its own app, as User(AbstractUser)*