My data model looks like this:
class Integer(models.Model):
integer_value = models.IntegerField(default=0)
current_price = models.DecimalField(max_digits=5, decimal_places=2, default=0.00)
share = models.IntegerField(default=0)
market = models.ForeignKey(
IntegerMarket,
on_delete=models.CASCADE,
related_name='integers',
default=None)
def __str__(self):
return str(self.integer_value)
class Meta:
ordering = ['integer_value']
The view I'm using is as follows:
class IntegerMarketDetailView(LoginRequiredMixin, DetailView):
model = IntegerMarket
template_name = 'integer_market_detail.html'
login_url = 'login'
In my template for a specific instance of IntegerMarket
, I want to find the minimum and maximum values of integer_value
so I can use them as the min and max axis values in JavaScript.
For example, if I have an IntegerMarket
instance with integers numbered 1 through 5, I need to extract 1 as the min value and 5 as the max value.
What's the simplest way to accomplish this task?