Why am I unable to query the date from my database in django?

Date format that is stored in the database

My database does have an item in the collection I want to query, and it returns the price correctly.

from django.db import models

# Create your models here.
class Dollar_price(models.Model):
  price = models.FloatField()
  date = models.DateTimeField()
  
  def __str__(self):
    print(self.date)
    return str("success")

The problem is that when I try printing self.date it says it's None. I don't know why this happens, nor how can I solve this.

Вернуться на верх