Created
December 18, 2017 19:22
-
-
Save bencleary/141d38bf8a0e1584a973f483fbc79870 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class ObjectOwnerMixin: | |
def get_queryset(self): | |
return self.model.objects.filter(author=self.request.user) | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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