I have a model with a decimal field. The output of:
def special_method(self):
return MyClass.objects.filter(product=self).order_by('-date_active')[0:1]
on this model is:
[<MyClass: 10.00>]
… and I have defined the following method on MyClass:
def __str__(self):
return str(self.rate)
This may be a silly question but how do I correctly return the decimal number instead of this strange object?
Thanks.
myclass_instance.ratewill give you the decimal number.[edit]
Your method will then be something like:
Or you might be able to do something like: