'how to convert date format in __range look up - django

I'm trying to search between two dates using __range but it expects to write hours during the search and raise this error :

['“2022-02-22data” value has an invalid format. It must be in YYYY-MM-DD HH:MM[:ss[.uuuuuu]][TZ] format.']

here is my models field

created_at = models.DateTimeField(auto_now_add=True)

and here is my views.py

def my_views(request):
    start = request.GET.get('from')
    end = request.GET.get('to')
    if start and end:
        total_price = MyModel.objects.filter(created_at__range=(start,end))
    else:
        total_price = MyModel.objects.all()

            <form action="" method="GET">
                <div class="col-12 p-1 mt-1 mx-auto text-center text-light pInside row">
                    <p class="col-12 col-sm-6 mx-auto text-left row">
                          
                        from 
                        <input type="date" class="form-control col-9 mr-1" name="from" id="from"> 
                    </p> 
                        
                    <p class="col-12 col-sm-6 mx-auto text-right row">
                          
                           to
                        <input type="date" name="to" class="form-control col-9 mr-1" id="to">   
                    </p>
                    <button class="btn btn-success col-8 col-sm-5 col-md-3 mx-auto">search</button>
                </div>
            </form>

i dont want to force the database to only get year, month and day, i have to change the created_at to strftime("%Y-%m-%d") in the filter, but i dont know how to achieve that?! thank you in advance ..



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source