tags:

views:

1132

answers:

2

Hello everyone,

My Django app started breaking all of a sudden and I cannot understand why. I can't even get it to run now. I'm running revision 11798.

When I use the stand-alone server to test my app, it suddenly started not importing csrf. I previously had it working perfectly. I tried to see what was up by using the shell and here was the result:

$ ./manage.py shell
Python 2.6.3 (r263:75184, Oct  2 2009, 07:56:03) 
[GCC 4.0.1 (Apple Inc. build 5493)] on darwin
>>> import django
>>> from django import middleware
>>> from django.middleware import csrf
Traceback (most recent call last):
  File "<console>", line 1, in <module>
ImportError: cannot import name csrf
>>>

I checked the filesystem to see if the file was there and it was (and intact). I am horribly confused. Can anyone help me out?

The Django error follows:

File "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/Django-1.1.1-py2.6.egg/django/core/servers/basehttp.py", line 279, in run
    self.result = application(self.environ, self.start_response)

  File "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/Django-1.1.1-py2.6.egg/django/core/servers/basehttp.py", line 651, in __call__
    return self.application(environ, start_response)

  File "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/Django-1.1.1-py2.6.egg/django/core/handlers/wsgi.py", line 230, in __call__
    self.load_middleware()

  File "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/Django-1.1.1-py2.6.egg/django/core/handlers/base.py", line 42, in load_middleware
    raise exceptions.ImproperlyConfigured, 'Error importing middleware %s: "%s"' % (mw_module, e)

ImproperlyConfigured: Error importing middleware django.middleware.csrf: "No module named csrf"
+4  A: 

If you (or your sysadmin) recently updated your Django install, you may be interested in this CSRF changes - backwards incompatible, dated 10/27/2009.

Peter Rowell
Thanks for the link, but I've seen it already. This is a new project so it has been built with the new stuff from the beginning.
SapphireSun
Do you have more than one copy of Django in your python path?
Joe Holloway
I don't believe so (I once made a temporary installation, but I have since deleted it).
SapphireSun
Wow, actually I just triple checked it and you're right. My old install that I thought was gone was actually the one getting called. If you write that comment as an answer I'll give you an accepted answer.
SapphireSun
Aww.... Joe was right, but don't I get 1/2 a point? :-)
Peter Rowell
I gave you a +1 :)
Joe Holloway
Thanks! Actually I was just fooling around. My wife was looking over my shoulder and asking what I was doing. I tried to explain both what Stack Overflow was (as a site and as a concept) and what the question was about (I've been trying to explain tech to her for 20 years, but I don't think I'm making much headway). Anyway, she was the one who said they should give "partial credit." She, being a professional editor, also thought they should take off points for spelling and grammar errors, but I explained that just the idea of that could bring down the entire Intertubes.
Peter Rowell
So, you're saying she wants to turn StackOverflow into this: http://bit.ly/5OkddV ? ;)
Joe Holloway
Not quite. What she would really like to do is purge the world of neologisms, portmanteaus, and all instances of nouns being verbed and verbs being nouned! :-)
Peter Rowell
In that case, have her create a StackExchange site for editors!
Joe Holloway
+3  A: 

Do you have more than one copy of Django in your python path? Make sure you don't have any old installs laying around.

Joe Holloway