Opened 12 years ago

Closed 12 years ago

Last modified 12 years ago

#19555 closed Cleanup/optimization (fixed)

tutorial pt 1 - update year for examples to work

Reported by: rodrigorosa.lg@… Owned by: nobody
Component: Documentation Version: dev
Severity: Normal Keywords: year
Cc: Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: yes UI/UX: no

Description

last part executes:

Choice.objects.filter(pollpub_dateyear=2012)

and now we're in 2013 :)
happy new year!

salú
rela.

Attachments (1)

19555.diff (1.3 KB ) - added by Tim Graham 12 years ago.

Download all attachments as: .zip

Change History (11)

comment:1 by Aymeric Augustin, 12 years ago

Resolution: wontfix
Status: newclosed

Thanks for the report, but docs use various dates between 2005 and now as examples, and it doesn't add much value to change them every year.

comment:2 by Claude Paroz, 12 years ago

Easy pickings: set
Resolution: wontfix
Status: closednew
Triage Stage: UnreviewedAccepted
Type: UncategorizedCleanup/optimization
Version: 1.4master

As discussed on IRC:

mYk: claudep: mmmm, yeah, we should use a different example then
mYk: filter on a field other than the date

comment:3 by Aymeric Augustin, 12 years ago

I hadn't noticed that the tutorial created objects with the date set to "now", and then proceeded to filter on the year.

comment:4 by thiagocavila@…, 12 years ago

I think this should solve the problem:

Instead of:

from django.utils import timezone
p = Poll(question="What's new?", pub_date=timezone.now())

You make a fix date doing:

from django.utils import timezone
from datetime import datetime
timezone = timezone.get_current_timezone()
p = Poll(question="What's new?", pub_date=datetime(year=2013, month=10, day=10, tzinfo=timezone))

Then the date will be 2013/10/10 forever, no need to change it in 2014 =)

comment:5 by static, 12 years ago

Another much simpler solution is to filter by a not hardcoded year:

# Get the poll whose year is current year.

from datetime import datetime
Choice.objects.filter(pollpub_dateyear=datetime.now().year)

<Poll: What's up?>

...

# Find all Choices for any poll whose pub_date is in current year.

Choice.objects.filter(pollpub_dateyear=datetime.now().year)

---

I would also recommend editing the 2012 to 2013, as the 1.5 version is going to be released this year.

by Tim Graham, 12 years ago

Attachment: 19555.diff added

comment:6 by Tim Graham, 12 years ago

Has patch: set

I am in favor of keeping the date lookups, since I think it's useful to demo them (plus there aren't really any other fields on Poll to filter by).

The alternative of creating the poll with a specific date or assigning a specific pub_date later as was done before [e0d78f898f] so that the queries aren't dependent on timezone.now() would make the part later in the tutorial that says "If the value of "Date published" doesn't match the time when you created the poll in Tutorial 1, it probably means you forgot to set the correct value for the TIME_ZONE setting" invalid.

Since the images later in the tutorial use 2012, I don't think we should update the shell output for p.pub_date.

comment:7 by Tim Graham <timograham@…>, 12 years ago

Resolution: fixed
Status: newclosed

In 99315f709e26ea80de8ea3af4e336dbdbe467711:

Fixed #19555 - Removed '2012' from tutorial 1.

Thanks rodrigorosa.lg and others for the report.

comment:8 by Tim Graham <timograham@…>, 12 years ago

In c95ae7729f713a300e67bf30e9506ba78919113a:

[1.5.x] Fixed #19555 - Removed '2012' from tutorial 1.

Thanks rodrigorosa.lg and others for the report.

Backport of 99315f709e from master

comment:9 by Tim Graham <timograham@…>, 12 years ago

In 89ba1b27b4442cbb43555f607ab7d0f189a2af50:

[1.4.x] Fixed #19555 - Removed '2012' from tutorial 1.

Thanks rodrigorosa.lg and others for the report.

Backport of 99315f709e from master

comment:10 by Tim Graham <timograham@…>, 12 years ago

In c95ae7729f713a300e67bf30e9506ba78919113a:

[1.5.x] Fixed #19555 - Removed '2012' from tutorial 1.

Thanks rodrigorosa.lg and others for the report.

Backport of 99315f709e from master

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