如何根据 base.html 的 url 做出特定的操作?
我在 base.html 中有两个 if 子句作为上下文语句。如果 GET 中有代数,则应显示给定的上下文。
我的 url.conf
from django.conf.urls.defaults import *
urlpatterns = patterns('',
(r'^algebra/$', 'algebra'),
(r'^mathematics/$', 'mathematics'),
)
我的伪代码中的 base.html
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN">
<html lang="en">
<body>
{% if algebra %}
<div>... -- do this -- </div>
{% endif %}
{% if math %}
<div>... -- do this -- </div>
{% endif %}