streeter / django-db-readonly Goto Github PK
View Code? Open in Web Editor NEWForce an entire site to become readonly. In a sort of hackish way.
License: MIT License
Force an entire site to become readonly. In a sort of hackish way.
License: MIT License
This expects a package called readonly
which doesnt exist
tests_require=["readonly..."]
Goal is to avoid restarting server instance
Is this library compatible with python3.7? thanks.
Can I use this app to ignore the write sql?
I'm replicating a db to a slave, which is readonly.
(and want to see the data in the db)
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']
The following settings directive
MIDDLEWARE_CLASSES = (
# ...
'readonly.middleware.DatabaseReadOnlyMiddleware',
# ...
)
Doesn't work for the new Django 1.10 MIDDLEWARE new-style setup.
MIDDLEWARE = [
# ...
'readonly.middleware.DatabaseReadOnlyMiddleware',
]
See https://docs.djangoproject.com/en/1.10/releases/1.10/#new-style-middleware
You end up with an error like this:
File "/.../appname/wsgi.py", line 14, in <module>
application = get_wsgi_application()
File "/.../pythonenv/python3.5/lib/python3.5/site-packages/django/core/wsgi.py", line 14, in get_wsgi_application
return WSGIHandler()
File "/.../pythonenv/python3.5/lib/python3.5/site-packages/django/core/handlers/wsgi.py", line 153, in __init__
self.load_middleware()
File "/.../pythonenv/python3.5/lib/python3.5/site-packages/django/core/handlers/base.py", line 82, in load_middleware
mw_instance = middleware(handler)
TypeError: object() takes no parameters
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.