Как разместить окно поиска в моем приложении django?

мой код, пытающийся сделать окно поиска для поиска книг здесь, я пытаюсь сделать окно поиска, когда пользователь вводит название книги, как google, он будет показан на странице, когда я добавляю {{form}} в файл book.html он должен показать окно, но он не делает,

views.py:

def books(request):
      if request.method == 'POST':
        form = DashboardFom(request.POST)
        text = request.POST['text']
        url = 'https://www.googleapis.com/books/v1/volumes?q='+text
        r = requests.get(url)
        answer = r.json()
        result_list = []
        for i in range(10):
            result_dict = {
                'title':answer['items'][i]['volumeInfo']['title'],
                'subtitle':answer['items'][i]['volumeInfo'].get('subtitle'),
                'description':answer['items'][i]['volumeInfo'].get('description'),
                'count':answer['items'][i]['volumeInfo'].get('pageCount'),
                'catagories':answer['items'][i]['volumeInfo'].get('catagories'),
                'rating':answer['items'][i]['volumeInfo'].get('pageRating'),
                 'thumbnail':answer['items']   [i]['volumeInfo'].get('imageLinks').get('thumbnail'),
                 'preview':answer['items'][i]['volumeInfo'].get('previewLink')
            }
            result_list.append(result_dict)
            context={
                'form':form,
                'result':result_list,
            }
        return render(request,'dashboard/books.html',context)            
    else:
        form = DashboardFom()
    context = {'form':form}
    return render(request,'dashboard/books.html',context)

forms.py:

class DashboardFom(forms.Form):
    text = forms.CharField(max_length=100,label='Enter your search : ')

а также мой books.html:

    {% extends 'dashboard/base.html' %} 
    {% load static %} 
    {% block content %}
    <section class='text-center container'>
        <h2>Search books and browse your favorite</h2>
        <p>just enter the search query to obtain the results</p><b></b>
        <form action="" method="POST">
            {% csrf_token %}
            {{form}}
            <input class="btn btn-danger" type="submit" value="Submit">
        </form><br>

    {% for result in results %}
        <a href="{{result.preview}}" target="_blank">
            <div class="card">
                <div class="card-header">
                    <div class="row">
                        <div class="col-md-3">
                            <img class="img-fluid" src="{{result.thumbnail}}" alt="">

                        </div>
                        <div class="col-md-9">
                            <h3 class="p-0 m-0">{{result.title}}</h3>
                            <b>
                                <u>
                                    <h5 class="p-0 m-0">{{result.subtitle}}</h5>
                                </u>
                            </b>
                            {% if result.description %}
                                <h6 class="p-0 m-1">{{result.description}}</h6>
                            {% endif %}
                            <b> 
                            {% if result.categories %}
                                <h6 class="ml-0 mt-3">Category: 
                                    {% for category in result.categories  %}
                                        {{category}} 
                                    {% endfor %}
                                </h6>
                                {% endif %}
                                {% if result.count %}
                                <h6 class="ml-0 mt-1">Pages: {{result.count}}</h6>
                                {% endif %}
                                {% if result.rating %}
                                <h6 class="ml-0 mt-1">Rating: {{result.rating}}</h6>
                                {% endif %}
                            </b>
                        </div>
                    </div>
                </div>
            </div>
        </a>
    {% endfor %}
        <br>
    </section>
    {% endblock content %}

Есть ли у вас какие-нибудь идеи, что это происходит? также я делаю часть youtube, как это, icant see the box there too.

text = forms.CharField(max_lenght=100, label='...', widget=forms.TextArea())

https://docs.djangoproject.com/en/4.0/ref/forms/widgets/

Обратитесь к этому видео. В нем объясняется, как добавить строку поиска в ваше приложение. Приложение этого человека может быть другим, но следуйте тому, что он говорит, и когда вы все сделаете правильно и выполните все шаги, у вас будет готова панель поиска...

https://www.youtube.com/watch?v=AGtae4L5BbI

Вернуться на верх