Skip to content

Instantly share code, notes, and snippets.

@julianwachholz
Created June 18, 2013 16:13
Show Gist options
  • Save julianwachholz/5806721 to your computer and use it in GitHub Desktop.
Save julianwachholz/5806721 to your computer and use it in GitHub Desktop.
class ImageQuerysetMixin(object):
"""
Make sure to use the correct arguments for getting a single image.
With this mixin it's not possible to request an image just by its
primary key, we'll also need the correct username.
"""
def get_queryset(self):
return self.model.objects.filter(
pk=self.kwargs.get('pk', None),
user__username=self.kwargs.get('user', None)
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment