how should store parameters application configuration? example. i've application calculation of taxes in project. there few values need save once long time without changes possibility edit them(taxes, payment commissions, etc). should create config.py file or create model config? maybe there other way.
if want configurate parameters in calculation, go model object , initial fixture. because it's stored in database, can change anytime.
for example:
class setting(models.model): key = models.charfield(max_length=255, blank=false, null=false, unique=true) value = models.integerfield(blank=false, null=false) description = models.textfield(blank=true, null=true) def __str__(self): return self.key
and fixture (https://docs.djangoproject.com/en/1.9/howto/initial-data/):
[ { "model": "myapp.setting", "pk": 1, "fields": { "key": "[some_parameter_key]", "value": "[some value]", "description": "[some description]" } } ]
Comments
Post a Comment