In tutorial02 the was_published_recently section of the example may be defective?
|Reported by:||zjooji+django@…||Owned by:||nobody|
|Has patch:||no||Needs documentation:||no|
|Needs tests:||no||Patch needs improvement:||no|
I was going through part 2 of the tutorial and I ran into some errors when I was doing the was_published_recently section of the tutorial.
Firstly, the debugger kept telling me
was_published_recently() takes exactly 1 argument (2 given)
I was able to overcome that by adding a second argument to the was_published_recently function.
After that there were some missing import statements for timezone and datetime I needed to add.
And finally the code
def was_published_recently(self): return self.pub_date >= timezone.now() - datetime.timedelta(days=1)
Had to be changed to
def was_published_recently(self, arg2) return arg2.pub_date >= timezone.now() - datetime.timedelta(days=1)
After all these changes, the example ran and appeared to be working as shown in the screenshot.
In case you are wondering I did check my django version and it is in fact 1.6
Apologies if I have made some obvious newb mistake and have caused some of this myself. Either way the import statements should probably be added to save people having to find them for themselves