Re: NameError: global name ‘datetime’ is not defined

2009-01-19 Thread Kenneth Gonsalves

On Monday 19 Jan 2009 3:01:29 pm jazz wrote:
> p.was_published_today() Traceback (most recent call last):
> File "", line 1, in File "c:\projects\mysite..\mysite\polls
> \models.py", line 11, in was_published_today return self.pub_date.date
> () == datetime.date.today() NameError: global name 'datetime' is not
> defined

you need to import datetime

-- 
regards
KG
http://lawgon.livejournal.com

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@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
-~--~~~~--~~--~--~---



Re: NameError: global name ‘datetime’ is not defined

2009-01-19 Thread Malcolm Tredinnick

On Mon, 2009-01-19 at 01:31 -0800, jazz wrote:
> p.was_published_today() Traceback (most recent call last):
> File "", line 1, in File "c:\projects\mysite..\mysite\polls
> \models.py", line 11, in was_published_today return self.pub_date.date
> () == datetime.date.today() NameError: global name 'datetime' is not
> defined
> 
> any help

This is the third time in a couple of hours that you've posted something
like this. So, a couple of items of general advice. Please take them in
the spirit they're offered:

(1) Just posting the very last line on the screen is not that helpful.
It's like reporting there's a car crash without mentioning where it is
or that you happened to be the driver. We don't have enough information
to say anything intelligent beyond "you haven't given us enough
information." It happens, from having seen lots of questions, that I can
guess you're working through the first part of the tutorial, but you're
not always going to be that lucky.

(2) The tutorial is not fundamentally broken. Thousands of people have
worked through it successfully. So if you're seeing things that appear
to be basic errors, like the above, go back a few steps, re-read things
and try to find what you've missed. All of the information needed to
construct the examples are in the tutorial text.

For example, the above error suggests you've omitted the "import
datetime" line. That is on the line exactly one line above where you're
seeing the error. So you don't have to look back very far to find the
problem in this case. You've already seen that case-sensitivity is
important (in an earlier message) and that not missing lines (in this
case) is important. So, please take your time. If you end up posting 6
or 12 messages a day, you're going to find that people simply don't have
the time or inclination to help you, because you're not taking the time
to help yourself first.

We're very helpful on this list, providing you realise you are one of
well over 10,000 people on a very high-volume list. You have to do some
reasonable level of homework/preparation before posting.

In any case, it's nice to see another person trying out Django. It might
well require a little getting used to, since you're also trying to learn
Python at the same time (I would *strongly* recommend working through
the Python tutorial at python.org, at a minimum, before starting to work
with Django, but people are free to attempt anything), but it's
generally a fun experience once you put in the necessary study time.

Regards,
Malcolm



--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@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
-~--~~~~--~~--~--~---



NameError: global name ‘datetime’ is not defined

2009-01-19 Thread jazz

p.was_published_today() Traceback (most recent call last):
File "", line 1, in File "c:\projects\mysite..\mysite\polls
\models.py", line 11, in was_published_today return self.pub_date.date
() == datetime.date.today() NameError: global name 'datetime' is not
defined

any help
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@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
-~--~~~~--~~--~--~---