0

I want to create a dinamic link in my view according to path in urls.py

urls.py

path('link_path/', views.link_view, name="link")

this is how it works in a template in any.html

<a href="{% url 'link' %}"> this link</a>

how can i create dinamic link in views.py which will lead to my path in urls.py?

def link_view(request):
    link = ???
    print(link)

i want link variable output be like this 127.0.0.1:8000/link_path

update:

from django.urls import reverse

print(reverse("link"))
oruchkin
  • 424
  • 3
  • 13

0 Answers0