[Answer]-Django: Template {% url %} tag, how to pass parameter from form

1👍

You could have the form action empty, so to the same view, and then in the view redirect using the POST data from the form.

<form action="" method="post">
<input type="text" class="form-control" name="MOVIE_ID">
<button type="submit" class="btn btn-danger">Kinopoisk Search by ID</button>
</form>

And then in the view

def searchView(request):
    if request.method == 'POST':
        # get variables from form and redirect
    else:
        # do your normal rendering
👤Youri

0👍

(r'^kinoscrap/(?P<kinoid>\d+)/(?P<shortid>\d+)/$', kinoscrap),

Your urls.py accepts to integer values in the url (something like kinnoscrap/12/21), if you pass anything beside integers it’ll throw an error. If you want to pass a text field you’ll have to change the regular expression.

Try out your regexes at regex101 here to see if they’ll work.

Leave a comment