I am building a BlogPost Webapp and I am stuck on an Error.
When i try to check browser then it is keep showing
tzinfo argument must be None or of a tzinfo subclass, not type 'datetime.datetime'.
models.py
class Profile(models.Model):
user = models.OneToOneField(User, on_delete=models.CASCADE,default='',unique=True)
full_name = models.CharField(max_length=100,default='')
time = models.DateTimeField(auto_now_add=True)
@property
def age(self):
current_datetime = datetime.now(tz=timezone.now())
return (current_datetime - self.time).days
I also tried to change the time zone by :-
>>> from datetime import datetime
>>> import pytz
>>> d = datetime.fromtimestamp(0)
>>> pacific = pytz.timezone('US/Pacific')
>>> pacific
<DstTzInfo 'US/Pacific' PST-1 day, 16:00:00 STD>
>>> pacific_date = pacific.localize(d)
>>> pacific_date
datetime.datetime(1969, 12, 31, 17, 0, tzinfo=<DstTzInfo 'US/Pacific' PST-1 day, 16:00:00 STD>)
BUT Still same error
I have no idea, What is causing that Error.
Any help would be Appreciated.
Thank You in Advance