I am making a blog with django. I have an entry class, with title, content, publish date, etc.
The date field should save the date when the entry was created. But it changes if I edit the entry(If i changes the content or the title)
This is the code of the model:
class Entry(models.Model):
title = models.CharField(max_length=70)
content = models.TextField()
pub_date = models.DateTimeField(auto_now=True)
image = models.TextField()
tags = models.ManyToManyField(Tag)
def __unicode__(self):
return self.title
class Admin:
pass
class Meta:
ordering = ['-pub_date',]
Change
auto_nowtoauto_now_add.From django docs: