0
我有一個Django應用程序,用戶可以在2種接口模式之間進行選擇,該模式會影響這些網頁一些網頁...我使用不同的模板擦除模板緩存
在urls.py我有這樣的事情:
mode = Config.objects.get().mode
urlpatterns = patterns('',
url(r'^my_url/$', 'custom_view', {'template':'my_template.html', 'mode':mode}),
)
然後我的看法是這樣的:
@render_to()
def custom_view(request, template, mg=False, login=True):
if mode:
template = template + 'x' #I add an x to the template name to advice to django I that it should use the mode_2 template.
return {'TEMPLATE':template}
當用戶(在我的自定義配置頁)選擇模式2,模式不會改變,直到服務器重新啓動我的問題是(EIT她的apache或runserver.py是一樣的)。
我覺得這做緩存的東西,但我找不到如何清除高速緩存。 (每次Config.mode改變。)
+1。 'urls.py'只加載一次。它不是動態配置的最佳位置。 – 2010-09-20 07:03:07
+1。我們有一個'startup.py',它由'urls.py'導入並用來包含一次性啓動腳本。 – 2010-09-20 14:10:33