Reputation: 601
I want to save some defined variables in Django (simply said, a model class with only one instance).
For that currently I'm making a model and using model.object.get( pk=1 )
to get the variable values.
Other option I know about is creating a simple text file and storing variables(as a dict etc.). And reading through that whenever some change is required.
Is there some other easier way of doing that ?
Upvotes: 4
Views: 3472
Reputation: 4633
django-constance is a really good option.
Easily migrate your static settings to dynamic settings.
Admin interface to edit the dynamic settings.
https://github.com/jazzband/django-constance
Upvotes: 1
Reputation: 12080
If you're looking to just store a single, static value, then just keeping it in your settings.py
is sufficient as others have mentioned.
But if you require that users are able to edit it, may I suggest django-aboutconfig
? Disclaimer: I am the maintainer of that plugin
Upvotes: 2