Opened 3 years ago

Closed 3 years ago

Last modified 3 years ago

#19403 closed Uncategorized (invalid)

timezone missing error

Reported by: anonymous Owned by: nobody
Component: Documentation Version: 1.4
Severity: Normal 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

When I did this part of the turorial:

Just for good measure, let's also include the was_published_recently custom method from Tutorial 1:

class PollAdmin(admin.ModelAdmin):

# ...
list_display = ('question', 'pub_date', 'was_published_recently')

Adding 'was_published_recently' to list_display in admin.py would cause an error: "Global name timezone not defined"

I added this to the top of models.py to fix it:
from django.utils import timezone

to get rid of the error

Change History (2)

comment:1 Changed 3 years ago by timo

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

You must have missed the part in tutorial 1 where it instructs to add that import.

comment:2 Changed 3 years ago by anonymous

See about this error in version 1.5-alpha-1
https://code.djangoproject.com/ticket/19793#ticket

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