Django获取视图网址

# views.py
def add2(request, a, b):
    c = int(a) + int(b)
    return HttpResponse(str(c))
 
 
# urls.py
urlpatterns = patterns('',
    url(r'^add/(\d+)/(\d+)/$', 'app.views.add2', name='add2'),
)
 
 
# template html
{% url 'add2' 4 5 %}


home4.html

 {% url 'add2' 4 5 %}
 
    {% url 'add2' 4 5 as the_url %}
    链接到:{{ the_url }}

Django获取视图网址_第1张图片

你可能感兴趣的:(django)