سؤال

How do you ensure that a User can only edit objects they've created? What's the best way to set this up?

I'm using django-rest-framework and wondering if there's a way I can restrict users from viewing/ editing objects they don't 'own'.

class Video(models.Model):
    owner = models.ForeignKey(User)
    ...

So User 'x' should only be able to edit videos in their owner_set.

لا يوجد حل صحيح

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top