How to provide a URL link from one app's template to the homepage which is in the root urls.py in Django?

I have to give a link to the homepage which happens to be the login page of my website, from an app's template, that is:

<small style="margin-top: 5px;">To login<a href="{% url 'login' %}" class="login">Click Here</a></small>

Now, the problem in the URL tag is that the link is available in the root urls.py:

urlpatterns = [
    path('admin/', admin.site.urls),
    path('', views.login, name='login'),
]

How do I do this?

I managed to do it like this. There is a 'bboard' application, the login and info views are in the application. In the urls.py file (the configuration folder where the settings.py file is located) I register the import of the application with the desired view:

from bboard.views import login

Replace bboard with the name of your application everywhere.

urls.py(configuration folder)

from bboard.views import login

urlpatterns = [
    path('admin/', admin.site.urls),
    path('', include('bboard.urls')),
    path('login/', login, name='login'),

]

urls.py(application)

from django.urls import path
from .views import *

urlpatterns = [
    path('info/', info, name='info'),
   ]

views.py

def login(request):

    return HttpResponseNotFound("<h2>12345</h2>")

def info(request):

    return render(request, 'bboard/templ.html')

templates

<a href="{% url 'login' %}">Link</a>
Back to Top