How to get object in views.py using name not by id.
def StockSummaryPage(request, title):
stocks_data = get_object_or_404(Stock, string=title)
return render(request, 'stocks/stock_summary_page.html', {'stocks_data':stocks_data})
This is my views.py and in
stocks_data = get_object_or_404(Stock, string=title)
we use pk= stock_id but i want to do it by title. So help me
filter()(eg.Stock.objects.filter(string=title)get_object_or_404(Stock, string=title)?