[Fixed]-Django datetime comparison returning None – Why?

1👍

It’s possible that the template engine is swallowing an error in the property. Try accessing product.is_active_by_date in the view to see what it returns.

If you have timezone support enabled, you should use timezone.now() instead of datetime.now().

from django.utils import timezone

class Product(models.Model):
    @property
    def is_active_by_date(self):
        if self.use_activation_date:
        if timezone.now() < self.activation_date:

Leave a comment