Code

Opened 6 years ago

Closed 6 years ago

#7211 closed (invalid)

cannot import name hours_ahead

Reported by: selecter@… Owned by: nobody
Component: Uncategorized Version: 0.96
Severity: Keywords:
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:

Description

#cannot import name hours_ahead
#Request Method: GET
#Request URL: http://localhost:8000/time/plus/1/
#Exception Type: ImportError
#Exception Value: cannot import name hours_ahead

#urls.py:
from django.conf.urls.defaults import *
from views import current_datetime, hours_ahead

urlpatterns = patterns(,

(r'time/$', current_datetime),
(r'
time/plus/(\d{1,2})/$', hours_ahead),

)

#views.py:
from django.http import HttpResponse
import datetime

def current_datetime(request):

now = datetime.datetime.now()
html = "It's now %s." % now
return HttpResponse(html)

def hours_ahead(request, offset):

offset = int(offset)
dt = datetime.datetime.now() + datetime.timedelta(hours=offset)
html = "In %s hour(s), it will be %s." % (offset, dt)
return HttpResponse(html)

Attachments (0)

Change History (2)

comment:1 Changed 6 years ago by HappyCoder <selecter@…>

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset

comment:2 Changed 6 years ago by Simon Greenhill

  • Resolution set to invalid
  • Status changed from new to closed

Please take support questions to the django-users mailing list, thanks!

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.