Django

Code

Ticket #7211 (closed: invalid)

Opened 2 months ago

Last modified 3 weeks ago

cannot import name hours_ahead

Reported by: selecter@gmail.com Assigned to: nobody
Milestone: Component: Uncategorized
Version: 0.96 Keywords:
Cc: Triage Stage: Unreviewed
Has patch: 0 Needs documentation: 0
Needs tests: 0 Patch needs improvement: 0

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

Change History

05/10/08 07:29:12 changed by HappyCoder <selecter@gmail.com>

  • needs_better_patch changed.
  • needs_tests changed.
  • needs_docs changed.

06/14/08 02:08:22 changed by Simon Greenhill

  • status changed from new to closed.
  • resolution set to invalid.

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


Add/Change #7211 (cannot import name hours_ahead)




Change Properties
Action