[Fixed]-How to get keyword from html template – Django

1👍

Any view can implement both “get” and “post” handling; that way you can have something like

class BookCreateView(views.View):
    # subclass the basic form and add an hidden input named search
    form = your_custom_search_form
    # subclass the create model form
    confirmation_form = your_custom_create_model_form

def get(request):
    # show the empty search page
    # in your template use the form to implement search

def post(request):
    # handle the book search; there is a data in the payload named search
    # you now have a payload to use; here you make a database query 
    # and return the similar books; every book is printed in the page
    # using the your_custom_create_model_form that you can prepopulate

    # handle the confirmation of the book otherwise; the post
    # payload will contain the book information
👤edoput

Leave a comment