1. Luke Plant
  2. django-piston


James Emerton  committed 4de2991

Now supporting Handler.list_fields to restrict fieldset when multiple records are returned

Comments (0)

Files changed (1)

File piston/resource.py Modified

View file
  • Ignore whitespace
  • Hide word diff
 from django.views.decorators.vary import vary_on_headers
 from django.conf import settings
 from django.core.mail import send_mail, EmailMessage
+from django.db.models.query import QuerySet
 from emitters import Emitter
 from handler import typemapper
         emitter, ct = Emitter.get(em_format)
-        srl = emitter(result, typemapper, handler, handler.fields, anonymous)
+        fields = handler.fields
+        if hasattr(handler, 'list_fields') and (
+                isinstance(result, list) or isinstance(result, QuerySet)):
+            fields = handler.list_fields
+        srl = emitter(result, typemapper, handler, fields, anonymous)