I
I
Igor Andreev2018-05-12 18:22:22
Django
Igor Andreev, 2018-05-12 18:22:22

Why can't find url "/search/" in django in html file?

Hi everybody!
Who can tell me why it does not find the url "/search/" in django?
"/search/" is highlighted and no
url is found "/search/" is defined in url.py
file "html" file

<body>
    <form action="/search/" method="get">
        <input type="text" name="q">
        <input type="submit" value="Найти">
    </form>
</body>

file "url.py" of module 'polls'
urlpatterns = [
    ###
    path('', views.IndexView.as_view(), name='index'),
    path('search/', views.search, name='search'),
    ###
]

If I enter this, it works:
<body>
    <form action="http://127.0.0.1:8000/polls/search/" method="get">
        <input type="text" name="q">
        <input type="submit" value="Найти">
    </form>
</body>

Answer the question

In order to leave comments, you need to log in

1 answer(s)
K
Konstantin Malyarov, 2018-05-12
@Konstantin18ko

action="{% url 'search' %}"
Maybe so?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question