[Python] Get all objects with today date, django

Discussão em 'Python' iniciado por Stack, Junho 24, 2025.

  1. Stack

    Stack Membro Participativo

    I have a model like this

    class Maca(models.Model):
    created_at = models.DateTimeField(
    auto_now_add=True
    )


    Now I want in the views.py file to get all the entries that have created today,

    I'm trying this

    Maca.objects.filter(created_at=datetime.today().date())


    But this looks for the clock that object is created too.

    P.S I can't change the field in model because I need the clock too in other purposes.

    Can someone help me to select all entries that have been created today?

    Thanks in advance

    Continue reading...

Compartilhe esta Página