Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

[py3] Fixed middleware_exceptions tests.

  • Loading branch information...
commit 27d16a3ca4a330f5aa46015ccd7d5a9ee72873b6 1 parent 24de85c
Aymeric Augustin authored

Showing 1 changed file with 5 additions and 4 deletions. Show diff stats Hide diff stats

  1. 9  django/core/handlers/base.py
9  django/core/handlers/base.py
... ...
@@ -1,6 +1,7 @@
1 1
 from __future__ import unicode_literals
2 2
 
3 3
 import sys
  4
+import types
4 5
 
5 6
 from django import http
6 7
 from django.core import signals
@@ -125,10 +126,10 @@ def get_response(self, request):
125 126
 
126 127
                 # Complain if the view returned None (a common error).
127 128
                 if response is None:
128  
-                    try:
129  
-                        view_name = callback.func_name # If it's a function
130  
-                    except AttributeError:
131  
-                        view_name = callback.__class__.__name__ + '.__call__' # If it's a class
  129
+                    if isinstance(callback, types.FunctionType):    # FBV
  130
+                        view_name = callback.__name__
  131
+                    else:                                           # CBV
  132
+                        view_name = callback.__class__.__name__ + '.__call__'
132 133
                     raise ValueError("The view %s.%s didn't return an HttpResponse object." % (callback.__module__, view_name))
133 134
 
134 135
                 # If the response supports deferred rendering, apply template

0 notes on commit 27d16a3

Please sign in to comment.
Something went wrong with that request. Please try again.