Opened 19 years ago
Closed 19 years ago
#4037 closed (invalid)
need from / import
| Reported by: | chwolfe | Owned by: | Jacob |
|---|---|---|---|
| Component: | Documentation | Version: | dev |
| Severity: | Keywords: | ||
| Cc: | Triage Stage: | Unreviewed | |
| Has patch: | no | Needs documentation: | no |
| Needs tests: | no | Patch needs improvement: | no |
| Easy pickings: | no | UI/UX: | no |
Description
In the section in tutorial one,
import datetime
# ...
class Poll(models.Model):
# ...
def was_published_today(self):
return self.pub_date.date() == datetime.date.today()
I think the import line should be:
from datetime import datetime
I am somewhat new to python so maybe I'm doing something wrong.
Note:
See TracTickets
for help on using tickets.
No, it's correct. The Python standard module
datetimecontains classes nameddatetimeanddate. Doingimport datetimemakesdatetimethe _module_ available to you, so the two classes need to be referred to asdatetime.datetimeanddatetime.date.