Best way of linking to a page in Django

前端 未结 5 2169
臣服心动
臣服心动 2021-02-08 20:02

I managed to create a URL tag for my index. But right now I\'m confused how to add links to other pages.

I put this on my urls.py

url(r\         


        
5条回答
  •  太阳男子
    2021-02-08 20:56

    So next you would extend your urls.py to look something like this:

    url(r'^$', 'index', name='index'),
    url(r'^blog$', 'blog', name='blog'),
    

    Then in your html you can use either one:

    Home
    Blog
    

    You can of course use the template tage {% url 'index' %} as many times as you need in any template.

提交回复
热议问题