'How to get value from dropdown list in django

I am trying to create an application which gets date from a db and then gets input from the user and returns data for that specific user-input value. I am facing an error while doing this.

Views.py :

from django.shortcuts import render
from apple.models import predictions
from django.views.generic import View


# Create your views here.


def home_view(request):

    return render(request, 'homepage.html')


def post(request):

    company = str(request.POST.get("company-names"))

    final_date = request.POST["date1"]
    price = predictions.objects.filter(date=final_date)

    for x in price:
       pred = x.company
    
    return render(request, 'results.html', {'price': pred})


def back_view(request):
    return render(request, 'homepage.html')

Homepage.html :

<!DOCTYPE html>
{% extends "base.html" %}
{% block content %}

<html>

<body>
    <div class="login">
        <h1 id = "page-title">Predict Stock Prices</h1>
        <h3 id = "date-title">Enter date (in format - yyyy-mm-dd)</h3>
        <h3 id = "company-title">Choose Company</h3>




        <form action="post" method="post">
            {% csrf_token %}

            <select name="company-names" id="company-names" selected="selected">
                <option value="reliance">Reliance</option>
                <option value="tcs">TCS</option>
            </select>

            <!-- <input type="text" id="company-names" name="company-names" placeholder="Company from Nifty-50"> -->

            <input type="text" name="date1" placeholder="Date after ( 2020-02-18 )" id="date-form" />

            <input type="submit" id="button-submit" value="Predict" />
        </form>
    </div>
</body>

{% endblock %}

</html>

Error I am getting : Error

What my DB looks like : DB



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source