how to use the href attribute in django templates

前端 未结 2 613
小鲜肉
小鲜肉 2020-12-29 23:58

When I try to use a link in my Django template from /appname/index/ to get to /appname/detail/### I am instead getting to /appname/index/deta

2条回答
  •  青春惊慌失措
    2020-12-30 00:39

    From my experience, as long as you have defined the url of the page the href tag should lead to in urls.py, include the absolute path in the format below.

    Site name: yyyy.com
    Url of page to redirect to in urls.py: yyyy.com/signup/
    
    Sample link: Signup
    

    You will notice that what goes inside the href tag is sort of appended to the current url. For more dynamic links, you can use some python as of DTL guidelines.

提交回复
热议问题