Django error followup
Yesterday I wrote a quick post about breaking my Django install and didn’t think much of it.
So it was quite a surprise for me to get a comment from Adrian Holovaty, Django developer! He asked for some details on the errors I was getting, so I’ll try my best to explain exactly what the errors are and how they were generated…
Original install
The first night I tried Django, I grabbed the latest development snapshot using SVN. At the time that was revision 1363. I had previously installed and configured Apache2, PostgreSQL, and mod_python (and confirmed they worked) so I didn’t have to worry about that. With my PYTHONPATH set, I began to work through Part 1 and Part 2 of the tutorial. It went rather smoothly with no errors at all.
Update and breakage
Yesterday (never content to leave well enough alone), I decided it would be a good idea to update my Django source files to the latest in the repository. That updated me to revision 1480.
At that point I decided to check the site and make sure everything still worked before I continued with Part 3 and Part 4 of the tutorial. I found that the admin site that had previously been working was now generating some errors. Doh!
The error messages
The interesting part is that sometimes I get a mod_python error (error text here), and sometimes I get a Django ViewDoesNotExist error (screenshot here). I can’t say I spent a lot of time on it, but I was unable to determine why I get different errors at different times. It is always one or the other.
Today I found the Backwards-incompatible changes page on the Django site. According to that page, there are a few incompatible changes between 1327, 1443, and 1470. Granted, the listed incompatibilities don’t seem to match the errors that I’m seeing, but perhaps there is something to it.
Side note: I must mention that regardless of the cause of the error, Django has the coolest web app error pages I’ve ever seen. They not only look pretty, but with collapsable code/tracebacks they are extremely informative as well. It’s almost a pleasure to generate errors! ;)
Conclusion
As I said before, I’m more than content to just clean out what I did so far and start over with the tutorial. It’s no big deal to me. But I thought it might be helpful to post some more details in case anyone encounters the same problem I did (and because Adrian asked).
November 29th, 2005 at 9:02 pm
Thanks for the detailed explanation. I’m pretty sure you got hosed by .pyc files (byte-compiled Python modules). Subversion doesn’t manage .pyc files, and they can get left around in strange places, which makes them available to Python.
Generally here’s a good command to run between “svn update”s:
find -name “*.pyc” | xargs rm -i
(Run this from the django root package — the directory that contains “bin”, “conf”, “contrib”, “core”, etc.)
Here’s somebody who had a similar problem:
http://groups.google.com/group/django-users/browse_thread/thread/676445b56c5c69d7/aff37e7beea1261a
November 29th, 2005 at 9:12 pm
Ok, collapsable I will give you, but mod_mono/C#/asp.net for Linux gives a similar output when it fails to compile. I almost wish I had some broken code to show you. My Java induced coworkers are not convinced of the cool factor of the error pages, but obviously I am not alone in thinking that it is a good idea.
November 29th, 2005 at 9:13 pm
I should have said that perhaps C#/asp.net for M$ does the same thing. However I wouldn’t know.
November 29th, 2005 at 9:20 pm
Correction: In the “find -name “*.pyc” | xargs rm -i” example I gave in my previous comment, it should be this, leave off the “-i”.
November 30th, 2005 at 7:56 pm
Adrian:
In most modern implementations of find you can just do this:
find . -name ‘*pyc’ -exec rm -i \{\} \;
And in non-gnu find, you’ll need a “.” between find and -name.
November 30th, 2005 at 8:03 pm
[...] Hopfully this will be my last post related to my previously broken Django install. [...]
November 30th, 2005 at 8:08 pm
Heh, looks like I just needed to restart Apache. See my post from this evening for all the embarassing details. :)
November 30th, 2005 at 10:17 pm
tabo:
Thanks for the tips. Having learned Solaris before Linux, I was used to putting a . or * before -name. That was such an odd syntax!
March 24th, 2006 at 8:37 pm
Xin chao, Minh den tu HL, minh mong muon duoc lam quen voi tat ca cac ban. Thanks you