How to modify my ORM to show the date in the select?

I would appreciate your help friends since I am new and there are several things that I do not master!

I have a data record and a date is saved in each of the records, then I need to display the information depending on the date it was saved, when viewing the date data in my select it is displayed as follows

enter image description here

This is the code of my forms where I create the select, I imagine that the answer to my problem is to modify the ORM (which I have tried in several ways and I can't do it) and the data must be distinct so that the month does not repeat

class Report2Form(Form):
    reportDate = ModelChoiceField(
        queryset=ConsElect.objects.values_list('date', flat=True), 
        widget=Select(attrs={
            'class': 'form-control',
            # ('F , Y') This is how it appears to me as 'April, 2023'
        }),
    )

This is my model

class ConsElect(models.Model):
    pgd = models.ForeignKey(TipoPGD, on_delete=models.CASCADE, related_name='conselect')
    date= models.DateField(default=datetime.now)  
    read_morning = models.IntegerField(default=0)
    read_day = mod

I need help so that my select is as I need!



Comments

Popular posts from this blog

Spring Elasticsearch Operations

Network Error and Timeout on Authorize.net JS

Object oriented programming concepts (OOPs)