B
B
bituke2020-09-09 17:28:47
Django
bituke, 2020-09-09 17:28:47

How to change the path of a link in a website in django?

5f58e4f11ada4750968798.png
In short, when clicking on this button, the user should not go to catalog/catalog, but the link should lead just to catalog/
That is, when clicking on the Catalog button, on the catalog page, I get here:
5f58e66b295f0735284419.png
What should not be.
I use one master page template, does it have to be copied to change the link, or is it optional?
If anything, here is the code from the template that I don't want to copy to every application:

<a href="catalog/" class="link_catalog"><p class="link_catalog_cap">Каталог товаров</p></a>

If you change href to just ='/' then the main page will not go to the directory. In general, I hope I explained clearly, albeit clumsily.

In general, if possible, explain how this is all rationally done, because I'm a beginner and I'm sure I do everything through one place, as normal developers are not supposed to, thanks in advance!

Answer the question

In order to leave comments, you need to log in

2 answer(s)
D
Dr. Bacon, 2020-09-09
@bituke

Because you need to understand the difference between href="catalog/" and href="/catalog/", well, yes, as already mentioned, in django links are displayed through reverse, and url.

S
Sergey Tikhonov, 2020-09-09
@tumbler

Use the reverse function and its template counterpart url

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question