Reputation: 3730
In Django when I want to store models like users, places and so on I may use an SQL database, but when I want to store a particular value (only one) I have no idea what to use.
So, I'm doing a website where there is some information that changes monthly. Giving one example:
<meta name="description" content="This team is in {{ ranking }} in the world ranking">
I'll need to change that value, ideally from Django Admin monthly and a Model with one object seems too much (not too much work but simply too much).
I started looking at NoSQL and from this question I'm inclined to use Redis or a similar key-value DB.
Is it the right approach or am I completely off track?
Upvotes: 3
Views: 136
Reputation: 15400
I think for this case it better to use existing solutions like Constance - Dynamic Django settings. It is general solution for modifiable variables through django admin interface.
Here is list of similar apps https://djangopackages.org/grids/g/live-setting/
Upvotes: 1
Reputation: 2351
You could use python's shelve for a simple out-of-the-box solution for object persistence. It's easy to use:
with shelve.open('my_store') as my_store:
my_store['ranking'] = 10
and then:
with shelve.open('my_store') as my_store:
ranking = my_store['ranking']
Hope this helps!
Upvotes: 2