我刚刚在玩 django-satchmo 电子商店应用程序。 Satchmo 使用 satchmo-livesettings 或只是 livesettings 来实现这个目标。除此之外,还可以使用管理界面更改设置。
唯一的问题是我没有找到关于如何使用 livesettings 的教程。但是如果你浏览一下 satchmo 代码,你就会知道它是如何工作的。
这是我的例子
from livesettings import config_register, StringValue, PositiveIntegerValue
SHOP_GROUP = ConfigurationGroup('SHOP', ('ShirtSale Shop Settings'), ordering=0)
CHARGE_PORTO = config_register(
BooleanValue(SHOP_GROUP,
'CHARGE_PORTO',
description = ('Porto Erheben?'),
help_text = ("Wird bei Bestellungen zusaetzlich ein Porto erhoben?"),
default = True))
我已将这些行包含在 config.py 文件中。要执行此文件,必须:
import config
在 admin.py 文件中(我想知道这是否有必要)
为了访问设置,我在 urls.py 文件中包含以下内容:
(r'^settings/', include('livesettings.urls')),