Never mind I solved the problem!
For all of you with the same problem: it appears that the first time
that you use or import (i'm not really sure) a class in the python
shell, it's source-code file is compiled automatically in a ".pyc"
file, in the same directory where the source-code file is located and
with the same name.
After that everytime you import that class, the python interpreter
gets it from the ".pyc" file. You added the "was_published_today()"
method to the Poll class in the "models.py" file, but the "models.pyc"
file still contains the old version even after an re-import or reuse
of the Poll class. It seems that Python compiles the module only the
first time it is imported, and after that even if the source-code in
"models.py" changes, the python interpreter doesn't automatically
recompile the new version of the code. That's why the ".pyc" file
still has the old version of the Poll class and that's where the
Python interpreter imports the class from so you get the
Traceback (most recent call last):
  File "<console>", line 1, in <module>
AttributeError: 'Poll' object has no attribute 'was_published_today'
error in the interpreter.
I think that it has nothing to do with indentation or whitespaces. If
you delete the ".pyc" files for every file you change, then there
should be no more problems. Just go to polls/ directory and delete
"models.pyc" (or any other ".pyc" file if you had made changes to
"settings.py" or "urls.py").
Everything should work fine now.

-- 
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