Skip to content

Instantly share code, notes, and snippets.

@bencleary
Created December 18, 2017 19:22
Show Gist options
  • Save bencleary/141d38bf8a0e1584a973f483fbc79870 to your computer and use it in GitHub Desktop.
Save bencleary/141d38bf8a0e1584a973f483fbc79870 to your computer and use it in GitHub Desktop.
class ObjectOwnerMixin:
def get_queryset(self):
return self.model.objects.filter(author=self.request.user)
from django.views.generic.edit import *
from .models import *
from .mixins import *
class App(ObjectOwnerMixin, UpdateView):
template_name = 'test.html'
success_url = '/'
model = Posts
fields = ['title', 'body', 'author']
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment