Reputation: 948
I want a link in my webpage header bar that points to a certain part of a page (for example, the lower half). It's easily done with pure HTML but I wonder how to do it in django.
HTML version:
In base.html:
<a href="/entrance.html#intro">Introduction</a>
In entrance.html:
<a name="intro"></a>
How can I do the same thing in django? Any better solutions than just writing one more view function?
Upvotes: 1
Views: 2380
Reputation: 29
There's also another way to tag html elements by id AND use the url template tag from django:
https://engineertodeveloper.com/a-better-way-to-route-back-to-a-section-ids-in-django/
(Credits for Brian, who wrote the solution at the link above)
this can be very useful if you, for some reason, need to use the url method for creating your links.
Upvotes: 0
Reputation: 1691
There is no difference in doing it with Django when compared to just normal HTML. Just continue doing it the HTML way.
Upvotes: 2