I am using Django Admin to visualize and edit data of my Model. One of the model's field is date and unfortunately is a CharField but with a validator ( dd.mm.yyyy ). I am trying to figure out of a solution to sort those dates in the correct way when the admin press on the sort button that is default from django. In my experience with Java it was all about overwriting the compare function of the class.
data_de_montat = models.CharField(help_text="eg: 02.07.2020 or 12.9.2021", max_length=15, validators=[
RegexValidator(r'^[0-9]{1,2}.[0-9]{1,2}.[0-9]{4}$',
message='It should be dd.ll.aaaa',
code='wrong format'
)])
