I am new to django and i am creating my first project. I created one app in which model i define one postgres datatime field but i always get error for this field when run migrate command.
I used below value for datetime field in models.py but nothing happened
created=models.DateTimeField(default=timezone.now)
created=models.DateTimeField(default='', blank=True, null=True)
created=models.DateTimeField(blank=True, null=True)
created=models.DateTimeField(default='0000-00-00 00:00:00', blank=True, null=True)
in my settings.py
LANGUAGE_CODE = 'en-us'
TIME_ZONE = 'UTC'
USE_I18N = True
USE_L10N = True
USE_TZ = True
my models.py
from django.db import models
from django.utils import timezone
# from django.contrib.auth.models import User
# Create your models here.
class Operator(models.Model):
operator_code=models.CharField(unique=True, max_length=20)
operator_name=models.CharField(max_length=60)
operator_type=models.CharField(max_length=60)
short_code=models.CharField(max_length=60)
apiworld_code=models.CharField(max_length=20)
apiworld_operatortype=models.CharField(max_length=20)
active_api_id=models.IntegerField(default=1)
ospl_commission=models.DecimalField(default=0.00, max_digits=11, decimal_places=2)
apiworld_commission=models.DecimalField(default=0.00, max_digits=11, decimal_places=2)
image=models.CharField(max_length=100)
status=models.SmallIntegerField(default=1)
updated=models.DateTimeField(default=timezone.now)
created=models.DateTimeField(default=timezone.now)
def __str__(self):
return self.operator_code
when i run 'python manage.py migrate' i got below error how to remove this
'django.core.exceptions.ValidationError: ["'0000-00-00 00:00:00' value has the correct format (YYYY-MM-DD HH:MM[:ss[.uuuuuu]][TZ]) but it is an invalid date/time."]'