Skip to content

Conversation

@thinred
Copy link

@thinred thinred commented Jun 2, 2011

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.

@dcramer
Copy link
Contributor

dcramer commented Jun 2, 2011

Could you tell me why self.view_func would be unset? I mostly want to add test coverage for this case for future regressions.

@thinred
Copy link
Author

thinred commented Jun 2, 2011

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.

@thinred
Copy link
Author

thinred commented Jun 2, 2011

Yes, this triggers on every new project with Django 1.3.
You may use this (then just enter any URL different from ""):

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.

@apollo13
Copy link
Contributor

apollo13 commented Jun 2, 2011

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)

@thinred
Copy link
Author

thinred commented Jun 2, 2011

@apollo13:
You are right. Thanks for that: I added an additional commit with two unit tests to cover this issue.
@dcramer:
Is it ok?

dcramer added a commit that referenced this pull request Jun 3, 2011
Fixes error I encounter when no view is executed
@dcramer dcramer merged commit d9a2437 into django-commons:master Jun 3, 2011
@dcramer
Copy link
Contributor

dcramer commented Jun 3, 2011

I love you guys for providing the tests :)

@mjacksonw
Copy link

Nice! Can't wait for this to make it into a release!

ryneeverett pushed a commit to ryneeverett/django-debug-toolbar that referenced this pull request Oct 2, 2016
Fixes error I encounter when no view is executed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants