// models.py from django.utils import timezone class Product(models.Model): name = models.CharField(max_length=225) created_on = models.DateTimeField(auto_now_add=True) @property def is_new(self): now = timezone.now() diff = now - self.created_on if diff.days < 7: # 7 is the number of days return True else: return False // in your template <h4>{{ product.name }}{% if product.is_new %}<span>სიახლე</span>{% endif %}</h4>
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter