我想在基本模板中实现缓存:
<!DOCTYPE html>
<html lang="en">
{% load cache %}
{% load app_config %}{% verbose_name 'polls' as app_name %}
<head>
{% cache head %}
<meta charset="UTF-8">
<title>{% block title %}{% endblock %} - {{ app_name }}</title>
{% load static %}
<link rel="stylesheet" type="text/css" href="{% static 'polls/css/style.css' %}" />
{% endcache %}
</head>
<body>
{% cache header %}
<h2 id="header"><a href="{% url 'polls:index' %}">{{ app_name }}</a></h2><hr/>
{% endcache %}
{% block content %}{% endblock %}
</body>
</html>
有两个问题:
始终执行verbose_name templatetag。我怎么能阻止这个?
模板标签不接受None的超时,这意味着它永不过期。
答案 0 :(得分:1)
关于超时,您需要以秒为单位定义超时,Helpful Post Here
verbose_name
您需要添加条件才能执行<!DOCTYPE html>
<html lang="en">
{% load cache %}
{% load app_config %}
{% if condition %}
{% verbose_name 'polls' as app_name %}
{% endif %
<head>
代码
<GridLayout>
<ActionBar title="" backgroundColor="#f82462" top="0" left="0">
<NavigationButton (tap)="goBack()"></NavigationButton>
</ActionBar>
<GridLayout rows="*, auto">
<GridLayout row ='0' rows="auto *" columns="">
<GridLayout row="0" rows="" columns="">
<Button text="Top Button" (tap)="goNext()"></Button>
</GridLayout>
<GridLayout row="1" backgroundColor="#f82462">
<TextView [(ngModel)]="xyz" class="input" hint="Write your question as a complete sentence.Click on camera to add images if required." returnkeyType="done" id="questionText"></TextView>
</GridLayout>
</GridLayout>
<StackLayout row='1'>
<Button text="Next" (tap)="goNext()"></Button>
</StackLayout>
</GridLayout>