Opened 14 years ago
Closed 14 years ago
#16668 closed Bug (worksforme)
Problem with was_published_today()
| Reported by: | Owned by: | nobody | |
|---|---|---|---|
| Component: | Documentation | Version: | 1.3 |
| Severity: | Normal | Keywords: | |
| Cc: | Triage Stage: | Accepted | |
| Has patch: | no | Needs documentation: | no |
| Needs tests: | no | Patch needs improvement: | no |
| Easy pickings: | yes | UI/UX: | no |
Description
On https://docs.djangoproject.com/en/1.3/intro/tutorial01/, you write the following function:
def was_published_today(self):
return self.pub_date.date() == datetime.date.today()
This doesn't work (I tried it), as "today" returns a full datetime, instead of just a date (odd, I guess). Instead, you want:
def was_published_today(self):
return self.pub_date.date() == datetime.date.today().date()
Or something else that works.
Change History (2)
comment:1 by , 14 years ago
comment:2 by , 14 years ago
| Resolution: | → worksforme |
|---|---|
| Status: | new → closed |
| Triage Stage: | Unreviewed → Accepted |
Note:
See TracTickets
for help on using tickets.
The was_published_today should be returning a Boolean not the date.
I was unable to replicate the fault with the following commands.