3

Please note this is a Django issue and APPEND_SLASH = False does not work either. This is not a duplicate question as suggested. I need to do this inside the template.

How do you remove the ending slash in Django URLs so you can make href links to jump on sections of a webpage? If you have

a href="#section1"

And a url www.domain1.com/index, django makes it www.domain1.com/index/ so you get www.domain1.com/index/#secton1 when it should be www.domain1.com/index#section1.

Does anybody know?

Daniel Holmes
  • 1,952
  • 2
  • 17
  • 28
djangodeveloper
  • 213
  • 2
  • 7

1 Answers1

1

Just in case, If anyone is still looking for the answer -

In your HTML:

{% url 'index' as temporary_url %}
<a href="{{ temporary_url|slice:':-1' }}#secton1"> Link </a>