This the is model's code:
class LoanInfoStatusHistory(models.Model):
"""Model that saves a history of a loan."""
id = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False) # pylint: disable=invalid-name
loan = models.ForeignKey(Loan, on_delete=models.PROTECT)
previous_status = models.CharField(choices=Loan.LOAN_STATUS, max_length=20)
new_status = models.CharField(choices=Loan.LOAN_STATUS, max_length=20)
update_date = models.DateTimeField(auto_now_add=True)
def __str__(self):
"""
Unicode representation for a LoanInfoStatusHistory model.
:return: string
"""
return '{}: {} - {}'.format(self.loan.id, self.previous_status, self.new_status)
Is there a way to configure that the items are ordered by the date and time they were created?
date_created
field on your model. Maybe you should renameupdate_date
bydate_created
?