streeter / django-db-readonly

Force an entire site to become readonly. In a sort of hackish way.
MIT License
108 stars 21 forks source link

TypeError: 'dict' object is not callable #19

Closed hugochinchilla closed 5 years ago

hugochinchilla commented 5 years ago

Traceback:

File "/usr/local/lib/python3.7/site-packages/django/core/handlers/exception.py" in inner
  34.             response = get_response(request)

Exception Type: TypeError at /admin/
Exception Value: 'dict' object is not callable

Failing line context:

    This decorator is automatically applied to all middleware to ensure that
    no middleware leaks an exception and that the next middleware in the stack
    can rely on getting a response instead of an exception.
    """
    @wraps(get_response)
    def inner(request):
        try:
            response = get_response(request) …
        except Exception as exc:
            response = response_for_exception(request, exc)
        return response
    return inner

Local vars:

exc: TypeError("'dict' object is not callable")
get_response: {'SITE_READ_ONLY': False}
request: <WSGIRequest: GET '/admin/'>

Environment:

Request Method: GET
Request URL: http://127.0.0.1:8000/admin/

Django Version: 2.2.5
Python Version: 3.7.0
Installed Applications:
['django.contrib.admin',
 'django.contrib.auth',
 'django.contrib.contenttypes',
 'django.contrib.sessions',
 'django.contrib.messages',
 'django.contrib.staticfiles',
 'django_extensions',
 'logentry_admin',
 'rest_framework',
 'rest_framework.authtoken',
 'anymail',
 'phoenix',
 'api',
 'readonly']
Installed Middleware:
['whitenoise.middleware.WhiteNoiseMiddleware',
 'django.middleware.security.SecurityMiddleware',
 'django.contrib.sessions.middleware.SessionMiddleware',
 'django.middleware.common.CommonMiddleware',
 'django.middleware.csrf.CsrfViewMiddleware',
 'django.contrib.auth.middleware.AuthenticationMiddleware',
 'django.contrib.messages.middleware.MessageMiddleware',
 'django.middleware.clickjacking.XFrameOptionsMiddleware',
 'readonly.context_processors.readonly']
hugochinchilla commented 5 years ago

The error was mine, I copied the context processor in the place of the middleware.