AttributeError: 'QuerySet' object has no attribute 'objects', breaking the query attributes
Solution 1:
Your stocks
is already a QuerySet
, so you can obtain the values with:
if request.method == 'POST':
index = request.POST.get('dropdown_index')
stocks = Indexes.objects.filter(Symbol=index)
Open = stocks.values("Open")
High = stocks.values("High")
Close = stocks.values("Close")
Low = stocks.values("Low")
This will however make four queries to the database, you can fetch the values for Open
, High
, Close
and Low
all in the same query from the database:
if request.method == 'POST':
index = request.POST.get('dropdown_index')
stocks = Indexes.objects.filter(Symbol=index)
data = stocks.values("Open", "High", "Close", "Low")