streeter / django-db-readonly

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

Provide a way to enable readonly mode through admin interface #1

Open domenkozar opened 12 years ago

domenkozar commented 12 years ago

Goal is to avoid restarting server instance

streeter commented 12 years ago

Yeah, I've wanted this too. The thing that is tricky about it is you don't want to write to the database to turn if off. So you need another way to persistently store the setting. Memcache could be an option, but it isn't the best option.

domenkozar commented 12 years ago

Maybe just check if specific file exists?

On Mon, Sep 5, 2011 at 12:28 AM, streeter < reply@reply.github.com>wrote:

Yeah, I've wanted this too. The thing that is tricky about it is you don't want to write to the database to turn if off. So you need another way to persistently store the setting. Memcache could be an option, but it isn't the best option.

Reply to this email directly or view it on GitHub:

https://github.com/streeter/django-db-readonly/issues/1#issuecomment-1994271

pdr commented 12 years ago

You can use django-constance for dynamic settings. I realize this might only be a good option for those who already have redis running.

jayvdb commented 3 years ago

https://github.com/streeter/django-db-readonly/pull/22 starts the process, allowing turning it on and off programatically, and there is a note there for how we might be able to have it per-connection instead of all connections.

If we can make it per-connection, the default connection could be turned off, and another connection used only for this app using per-app routing. c.f. https://github.com/just-work/django-database-routing and many other db routers that support that.