'why i am getting this kind of error Validation Error?
ERROR: raise exceptions.ValidationError( django.core.exceptions.ValidationError: ['“” value has an invalid format. It must be in YYYY-MM-DD HH:MM[:ss[.uuuuuu]][TZ] format.']
models.py :
from django.db import models
from django.contrib.auth.models import User
from django.db.models.deletion import CASCADE
from django.utils.timezone import now
class Post(models.Model):
sno= models.AutoField(primary_key=True)
title= models.CharField(max_length=255)
author = models.CharField(max_length=13)
slug = models.CharField(max_length=130)
content= models.TextField()
timeStamp = models.DateTimeField(blank=True, null=True )
def __str__(self):
return self.title + ' by ' + self.author
class BlogComment(models.Model):
sno = models.AutoField(primary_key= True)
comment = models.TextField()
user = models.ForeignKey(User, on_delete=models.CASCADE)
parent = models.ForeignKey('self', on_delete=models.CASCADE, null=True)
timestamp = models.DateTimeField(null=True, blank=True)
Solution 1:[1]
Django does not treat ""
and None
the same in this instance. So you will want to validate user input to ensure that an unset date input is handled and changed from ""
to None
Check out this issue on the Django issue tracker for more info.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | user1720845 |