Skip to content

Instantly share code, notes, and snippets.

@guglielmo
guglielmo / mixins.py
Created January 29, 2013 18:48
This code is related to the django rest framework project (https://github.com/tomchristie/django-rest-framework). It's an implementation of the suggestion of Alan Plum in this google groups discussion (https://groups.google.com/forum/?fromgroups=#!topic/django-rest-framework/XRHdi8ddXiw) to have different representations of list and detail views…
from django.http import Http404
from rest_framework.mixins import ListModelMixin
from rest_framework.response import Response
class ShortListModelMixin(ListModelMixin):
"""
Extends ListModelMixin,
allowing the specification of the list_fields arguments for the .list() method
different fields can be shown for list and detail views
"""