Your code snippet works for me (though I'm just returning html rather than
the HttpResponse object, for testing purposes).

Be very sure that the spelling of everything in the file in question is correct
and that you aren't, for example, using the name "datetime" for something
else between the import and the usage.

If you're running in the development server, it is easy to stick in
pdb.set_trace()
(you'll have to import pdb) just before the offending line, and poke around when
you hit the breakpoint to see what datetime really is at that point.

If you don't hit the breakpoint, then you're not running with the file
you're editing.

Be sure that your really said "import datetime" rather than
"from datetime import datetime" (which is the way that I typically
import it) or that
someone else hasn't done that after your import.

If you're not running in the development server, then you might replace your
"now = ..." and "html = ..." lines with:
  html = "<html><body>datetime is %r.</body></html>" % datetime
which will tell you what datetime is at that point.  You will have to
restart apache
(or perhaps touch your .wsgi script file).

Bill

On Tue, Feb 9, 2010 at 5:19 PM, Nick Mellor
<nick.mellor.gro...@pobox.com> wrote:
> Thanks Shaun,
>
> I renamed the "now" variable as "dt" but it didn't help. I've also
> tried your 1-tuple idea-- no change.
>
> Note that the offending line isn't the html assignment but:
>
> now = datetime.datetime.now()
>
> On Feb 10, 6:22 am, Shawn Milochik <sh...@milochik.com> wrote:
>> Perhaps replace the bare 'now' with a tuple:
>>
>> Before:
>>
>> > html = "<html><body>It is now %s.</body></html>" % now
>>
>> After:
>>
>> > html = "<html><body>It is now %s.</body></html>" % (now,)
>>
>> Shawn
>
> --
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To post to this group, send email to django-us...@googlegroups.com.
> To unsubscribe from this group, send email to 
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at 
> http://groups.google.com/group/django-users?hl=en.
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.

Reply via email to