Commits

James Emerton  committed 4de2991

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

  • Participants
  • Parent commits 2b50b9c

Comments (0)

Files changed (1)

File piston/resource.py

 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
                 raise
 
         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)
 
         try:
             """