I am a beginner in Django and coding in general. I know that this must be an easy thing to do but I have been struggling with this for days.
This is my model:
class Bal(models.Model):
balance = models.IntegerField(default='5000')
def __int__(self):
return "{}, {}".format(self.pk, self.balance)
View:
def add_stock(request):
import requests
...
bala = Bal.objects.get(pk=2)
'''
return render(request, 'stocktrader/add_stock.html', {'ticker': ticker, 'output': output, 'bala': bala})
in the html page:
<h4>Balance: {{ bala }}</h4>
The output on the web page is:
Balance: Bal object (2)
Where "Bal object(2)" is I need it to display a number.
The table in the database has one 'balance' entry for 5000 and it has an id if 2. I just don't understand how to get the value of '5000' to display instead of 'Bal object (2)'.