从属下拉错误“元组”对象没有属性“获取”

时间:2020-08-29 16:11:55

标签: python django

   **PCR.html**


<div class="main-container">
            <p>PCR LIVE INDICATOR</p>
            <form method="POST" id="pcrchart" data-pcr-url="{% url 'ajax_expiry'%}">
                <div class="drop1">
                    <label>Select Symbol</label>

                    <select name="company" id="company" size="1">
                        <option value="" selected="selected">Nifty</option>
                        {%  for i in d %}
                        <option value="{{i.name}}">{{i.name}}</option>
                        {% endfor %}
                    </select>
                </div>


                <div class="drop2">
                    <label>Select Expiry</label>
                    <select name="expiryDate" id="expiryDate" size="1">
                        
                    </select>

                </div>
                <div class="drop3">
                    <label>Select Strike</label>
                    <br>
                    <select name="price" id="price" size="1">
                        <option value="" selected="selected">12700</option>
                        {% for Price in Prices %}
                        <option value="{{price.pk}}">{{price.name}}</option>
                        {% endfor %}

                    </select>
                </div>

            </form>

pcr1.html

<option value="" selected="selected">27 Aug 2020</option>
{% for expiryDate in expiry %}
<option value="{{expiryDate.expiry}}" title="27 Aug 2020">{{expiryDate.expiry}}</option>
{% endfor %}

views.py

def pcr(request):
    d={}
    d = stock.objects.all()
    return render(request,'pcr.html',{"d":d})

def expiry(request):
    name1 = request.GET.get('company')
    print(name1)
    expiry=NFO.objects.all().filter(name=name1)   
    return (request,'pcr1.html',{
        'expiry': expiry,
    })

我正在写一个从属的下拉列表。根据第二个下拉列表中的值选择第一个下拉值,这是错误的,“ tuple”对象没有属性“ get” 请求方法:GET 要求网址:http://127.0.0.1:8000/ajax/expiry/?company=NIFTY Django版本:3.0.7 异常类型:AttributeError 异常值:

'tuple'对象没有属性'get'

异常位置:process_response,第26行中的/usr/local/lib/python3.8/dist-packages/django/middleware/clickjacking.py Python可执行文件:/ usr / bin / python3 python版本:3.8.3 Python路径:

['/ root / Documents / optionplus', '/usr/lib/python38.zip', '/usr/lib/python3.8', '/usr/lib/python3.8/lib-dynload', '/usr/local/lib/python3.8/dist-packages', '/ usr / lib / python3 / dist-packages', '/usr/lib/python3.8/dist-packages']

服务器时间:2020年8月29日,星期六20:57:06 +0530

0 个答案:

没有答案