Opened 5 years ago

Closed 5 years ago

#15883 closed Bug (invalid)

Error in tutorial 01 models.py when defining was_published_today()

Reported by: anonymous Owned by: nobody
Component: *.djangoproject.com Version: 1.3
Severity: Normal Keywords: tutorial, custo method
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX:

Description

http://docs.djangoproject.com/en/dev/intro/tutorial01/

This custom method is exposed as a example:

import datetime
# ...
class Poll(models.Model):

# ...
def was_published_today(self):

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


The return clause of this method should be: return self.pub_date == datetime.date.today()

Regards !

Change History (1)

comment:1 Changed 5 years ago by Johannes Dollinger

Needs documentation: unset
Needs tests: unset
Patch needs improvement: unset
Resolution: invalid
Severity: Release blockerNormal
Status: newclosed

pub_date is defined as a DateTimeField, thus self.pub_date is a datetime.datetime instance, not a datetime.date instance.

Note: See TracTickets for help on using tickets.
Back to Top