Django Programming

Django migration timeout

We had a table having more than 6 lakh records. Everytime we added a new field to the model, and ran the migration we got timeout. So, we did the following 3 step procedure

1) Opened psql with timeout options –

PGOPTIONS="-c statement_timeout=0" psql -U name

2) We extracted the sql to be executed in psql from south migrate –db-dry-run –verbosity=2

3) Then, ran the migration command with fake option

python migrate modelname –fake


Django Lessons – #2

I needed to record the IP address of the user as well as the admin for every action completed. And, this IP must show with each log entry. So, I used user_ip=request.META["REMOTE_ADDR"]). But, this did not work on the server. The IP was getting recorded as Why so? The information I got from the webfaction support was that

REMOTE_ADDR is because requests for your site are proxied through our front-end web server, which of course is on the local host.If you want the original IP of the request, then use

I did some research, and found about the concept of reverse proxy.

Some links