>[success] # 利用url name 反向解析 >[danger] ##### url 给url命名 ~~~ from django.conf.urls import url from . import views urlpatterns = [ #... url(r'^articles/([0-9]{4})/$', views.year_archive, name='news-year-archive'), #... ] ~~~ >[danger] ##### 在views 层 使用命名 ~~~ <a href="{%url 'news-year-archive' 2012%}">2012</a> {%for i in year_list%} <a href="{%url 'news-year-archive' i%}">{{i}}</a> {%endfor%} ~~~