Changes between Initial Version and Version 1 of Ticket #31994
- Timestamp:
- Sep 10, 2020, 9:29:14 AM (4 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
Ticket #31994
- Property Component Uncategorized → Documentation
- Property Resolution → invalid
- Property Status new → closed
-
Ticket #31994 – Description
initial v1 1 1 The following function produces an error in the Tutorial 2. It can be problematic for new users that are getting acquainted with Django and do not know how to fix this issue. 2 2 {{{ 3 3 class Question(models.Model): 4 4 # ... 5 5 def was_published_recently(self): 6 6 return self.pub_date >= timezone.now() - datetime.timedelta(days=1) 7 7 }}} 8 8 returns the following error: 9 9 … … 11 11 12 12 It is easily fixed invoking the date method from now in the following way. 13 13 {{{ 14 14 class Question(models.Model): 15 15 # ... 16 16 def was_published_recently(self): 17 17 return self.pub_date >= timezone.now().date() - datetime.timedelta(days=1) 18 }}}