Commits

Mikhail Korobov committed 3a7e8cb

Support for django 1.3 Response.templates attribute is added

Comments (0)

Files changed (1)

django_webtest/__init__.py

         # Add any rendered template detail to the response.
         # If there was only one template rendered (the most likely case),
         # flatten the list to a single element.
-        for detail in ('template', 'context'):
-            if data.get(detail):
-                if len(data[detail]) == 1:
-                    setattr(response, detail, data[detail][0]);
-                else:
-                    setattr(response, detail, data[detail])
-            else:
-                setattr(response, detail, None)
+        def flattend(detail):
+            if len(data[detail]) == 1:
+                return data[detail][0]
+            return data[detail]
+
+        response.context = None
+        response.template = None
+        response.templates = data.get('templates', None)
+
+        if data.get('context'):
+            response.context = flattend('context')
+
+        if data.get('template'):
+            response.template = flattend('template')
+        elif data.get('templates'):
+            response.template = flattend('templates')
 
         return response