Does anyone have a suggestion on how to create a system that allows me to change settings on the fly? For example, I have a textarea that users can fill, and right now it has a maximum character limit of 1000. Someday I might want to change it to 500, or 2000, or something else. So I do not want to put a limit on the model itself, lest I want to go through the nightmare of backing up the DB, run syncdb, re-import DB, such a nightmare just to change a simple value. I'd rather do a check through Javascript or a views.py code on the character length.
if (length > value_stored_somewhere)
throw error message
I thought I could just put these values in settings.py, or perhaps a separate local-settings.py, but that means if I want to change the value I would have to restart the app, right? Or I could be wrong, so please tell me if I am wrong.
I thought that the ideal way to do this would be to put the settings in the database, so administrators can change values on-the-fly without touching any .py files. I took a look at django-dbsettings but there doesn't seem to be any activity at all there.
Please give me suggestions and solutions. Thanks a lot!
By default, the configuration uses SQLite. If you're new to databases, or you're just interested in trying Django, this is the easiest choice. SQLite is included in Python, so you won't need to install anything else to support your database.
You are right with all your assumptions. You need to restart the app if you want to change settings (in any settings file). Right now there is no way to "change settings on the fly". There are a bunch of reusable apps outside handling so called Live Settings. Maybe you try one of these. Keep in mind that even you change settings on the fly you will not change behavior in Django (since Django or also other apps are using internal settings directly). For a custom app or project though, this is a good approach.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With