Fun and Pain with Django

Phew, yesterday, rather today was a crazy night. I was trying to put up a django application for registrations of various users. Start was good and quickly within two days I got a decent application with captcha and other required fields. I uploaded it, and without much pain I got registration page up yAy.
We always have a local Point Of Contact from college where we are organizing the workshop. Now it will be nice feature if we can allow him/her also to view the registrations. And even better would be, he/she is limited to all the registrations they are in charge of, not of all the registrations. So again django views are simply great and I wrote simple view to limit user to particular list only. Nishanth is also learning django for his PyTasks so I thought it would be good idea to work together for some while to enable this view. He will get idea of how things work and I can get help from his learnings. He came up with this awesome one-liner to read a file, line by line, split it on particular delimiter and then create dictionary out of two fields

dictionary = dict([line.strip().split('|') for line in open('filename')])

Okay so everything working as expected, we tried to run the code locally and it was smooth and impressive(heh some time self-appreciation is good :P).
Now we pushed the code to the server, made sure everything was okay and in place, reloaded the apache and refreshed the page and BOOM gone. The normal registration itself vanished and we were getting error message of django not able to load views.py function from the app. It was bad, and people are still using it for registrations. It was already 1 am, we thought it would be over by 1:05, we will have some snacks and a good night sleep. But this BOOM really scared me. So we sshed into server, tried using django shell, loaded views and it was working fine. Nishanth tried extensive googling to search for some solution and came across a thread which mentioned about some problem with django, wsgi and reloading of views when something is changed. He said lets restart apache which I ignored for a while. We kept on trying making some changes and hoping that this time it will work. We were about to revert back to previous working version of site repo(Yeah hg always helps in such grave situations) when Nishanth said, "lets try restarting apache". We did that and yAy we got the app up again and running. Although it was not fault of django directly, but still I will give it also some credits. Phew by that time it was already 2:30 in night and we were like, dude we should hurry up, H-8 canteen is about to close and we wont get anything to eat if we are late.