0
views.py:
   
def index(request):
        if request.method == "POST":
            from_date = request.POST.get("from_date")
            f_date = datetime.datetime.strptime(from_date, '%Y-%m-%d')
            print(f_date)
            to_date = request.POST.get("to_date")
            t_date = datetime.datetime.strptime(to_date, '%Y-%m-%d')
            print(t_date)
            global roles
            roles =  Scrapper.objects.all()
            # for i in roles:
            #     print(i.description)
            global find_description
            # find_description = Scrapper.objects.all().filter(created_at=f_date,updated_at=t_date)
            find_description = Scrapper.objects.all().filter(created_at=f_date,updated_at=t_date)
        print(find_description)

models.py 
from django.db import models
from django.db import connections
from django.utils import timezone


# Create your models here.
class Scrapper(models.Model):
    id = models.IntegerField(primary_key=True)
    full_name = models.CharField(max_length=100)
    slug = models.CharField(max_length=100)
    description = models.TextField(max_length=100)
    created_at = models.DateTimeField(default=True)
    updated_at = models.DateTimeField(default=True)
    class Meta:
        db_table = "test_table_1"

When I pass the data as filter to the database to get value there occurs error RuntimeWarning: DateTimeField Scrapper.created_at received a naive datetime (2022-11-09 00:00:00) while time zone support is active. My f_date= "2022-11-09 00:00:00" . Is there any solution for removing error

Ajay
  • 89
  • 6
  • https://stackoverflow.com/questions/18622007/runtimewarning-datetimefield-received-a-naive-datetime will be helpful to you – Ajay K Nov 25 '22 at 11:17

0 Answers0