Code

Opened 6 years ago

Closed 6 years ago

#6680 closed (invalid)

Error in 0.96 tutorial 1 documentation

Reported by: Colin Humber Owned by: nobody
Component: Documentation Version: 0.96
Severity: Keywords: Tutorial
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:

Description

The line within the Poll.was_published_today(self) function does not work:

return self.pub_date.date() == datetime.date.today()

The python shell complains that datetime.date object has no attribute 'date'. When I change the line to:
return self.pub_date == datetime.date.today()

it works fine.

Attachments (0)

Change History (1)

comment:1 Changed 6 years ago by mtredinnick

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Resolution set to invalid
  • Status changed from new to closed

pub_date should be a DateTimeField. It looks like you may have made it a DateField instead. A DateTimeField will mean the Python attribute should be a datetime.datetime}} object, which does have a {{{date() method.

Check your models (and database) carefully and, if you're still having troubles, post your models to the django-users list with an explanation of what's going wrong. I just worked through the tutorial quickly up to that point and it worked fine for me, so I suspect there's a typo on your end.

Add Comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
as The resolution will be set. Next status will be 'closed'
The resolution will be deleted. Next status will be 'new'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.