So i need to remove from date Time, so i only get date, year and month.
"2014-04-17T00:00:00" I looked at different opportunities but it didn't work
class Inventory(models.Model): manufacturer = models.CharField(max_length=255) model = models.CharField(max_length=255) description = models.TextField(max_length=255) count = models.IntegerField(max_length= 255, default=1) location = models.ForeignKey('Location', null=True, blank=True) cover = models.FileField(upload_to = 'static/images/', default = 'static/images/no-image.png') created = models.DateTimeField(auto_now_add=True) barcode = models.CharField(max_length=255) assigned = models.ForeignKey(User, blank=True, null=True) checked = models.BooleanField(default=False) modified = models.DateTimeField(default=datetime.datetime.now) tags = TaggableManager(through=None, blank=True) def __unicode__(self): return '%s' % date(self.modified, "n/j/Y") def format_date(obj): return obj.modified.strftime('%d %b %Y %H:%M') format_date.short_description = 'Modified'
DateField? Also instead ofmodified = models.DateTimeField(default=datetime.datetime.now)you can useauto_now=True, that will update the field every time it's changed.datetime.datetime.nowis a TZ-unaware timestamp, which might cause issues later on.obj.modified.date().isoformat()