-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Fixes error I encounter when no view is executed #171
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
Could you tell me why self.view_func would be unset? I mostly want to add test coverage for this case for future regressions. |
|
When the URL in the browser does not hit anything in urls.py, process_view is not called. I will prepare a simple project for you that triggers that. |
|
Yes, this triggers on every new project with Django 1.3. urls.py: from django.conf.urls.defaults import url, patterns
from django.http import HttpResponse
def whatever(req):
return HttpResponse(':)')
urlpatterns = patterns('',
url(r'^$', whatever),
)settings.py: DEBUG = True
TEMPLATE_DEBUG = DEBUG
ADMINS = tuple()
MANAGERS = ADMINS
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3', # Add 'postgresql_psycopg2', 'postgresql', 'mysql', 'sqlite3' or 'oracle'.
'NAME': '/tmp/sq.tmp', # Or path to database file if using sqlite3.
'USER': '', # Not used with sqlite3.
'PASSWORD': '', # Not used with sqlite3.
'HOST': '', # Set to empty string for localhost. Not used with sqlite3.
'PORT': '', # Set to empty string for default. Not used with sqlite3.
}
}
TIME_ZONE = 'America/Chicago'
LANGUAGE_CODE = 'en-us'
SITE_ID = 1
USE_I18N = True
USE_L10N = True
MEDIA_ROOT = ''
MEDIA_URL = ''
STATIC_ROOT = ''
STATIC_URL = '/static/'
ADMIN_MEDIA_PREFIX = '/static/admin/'
STATICFILES_DIRS = tuple()
STATICFILES_FINDERS = ('django.contrib.staticfiles.finders.AppDirectoriesFinder',)
SECRET_KEY = '))*0u-ko4bulu&avyzr1o*b&h3!&8^#5agvdylr)akw@3fy2xh'
TEMPLATE_LOADERS = ('django.template.loaders.app_directories.Loader',)
MIDDLEWARE_CLASSES = (
'django.middleware.common.CommonMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'debug_toolbar.middleware.DebugToolbarMiddleware',
)
ROOT_URLCONF = 'mockup.urls'
TEMPLATE_DIRS = tuple()
INSTALLED_APPS = (
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
'django.contrib.messages',
'django.contrib.staticfiles',
'debug_toolbar',
)If you give me some time, I will write a unit test for that. |
|
It is caused by a middleware which returns a response in process_request -- as soon as that's the case process_view isn't called and bam no self.view_func (if the returned response has mimetype html debug_toolbar then tries to kick in and fails) |
Fixes error I encounter when no view is executed
|
I love you guys for providing the tests :) |
|
Nice! Can't wait for this to make it into a release! |
Fixes error I encounter when no view is executed
Some time ago I started to get """RequestVarsDebugPanel' object has no attribute 'view_func'""" error.
It's caused by unset self.view_func value. This commit fixes the issue for me.
I'm not the first to notice it, though other patches didn't work for me.