One of my Django installation was running fine for a few months. Last week I had to add a new Django project to this server.
My setup was : CentOS 5.5, Apache, mod_wsgi and psycopg2 2.2.0.x
After I added the new project, I started getting random errors « can’t adapt ». It would work perfectly for a few hours than my users would start getting an annyoying 500 error.
I searched the web, this seems to be a rather common error…but everything I found was related to another issue or something that was fixed in the Django release that I’m using.
One of the first thing I tryed was to update psycoppg2 to 2.2.1.
Now I was gettinga little bit information as the error was now « can’t adapt type ‘Decimal’ ». That’s better, but I still didn’t know how to fix it.
I ended up posting a message in the django-user mailing.
Some nice folks had exactly the same problem and told me how to fix it. I simply had to change mod_wsgi configuration so that it would run on his own process group.
My original configuration :
<VirtualHost *:443>
ServerName site1.com
WSGIScriptAlias / /var/www/site1.wsgi application-group=%{GLOBAL}
</VirtualHost>
<VirtualHost *:443>
ServerName site2.com
WSGIScriptAlias / /var/www/site2.wsgi application-group=%{GLOBAL}
</VirtualHost>
Is now :
<VirtualHost *:443>
ServerName site1.com
WSGIDaemonProcess site1
WSGIScriptAlias / /var/www/site1.wsgi process-group=site1 application-group=%{GLOBAL}
</VirtualHost>
<VirtualHost *:443>
ServerName site2.com
WSGIDaemonProcess site2
WSGIScriptAlias / /var/www/site2.wsgi process-group=site2 application-group=%{GLOBAL}
</VirtualHost>
The only thing I find hard to understand is how undocumented that issue is. I wouldn’t think that I am the only one running with that kind of setup ?




24 août 2010 at 11 h 10 min
Thanks, just ran into the same problem. In my mod_wsgi config I had:
WSGIDaemonProcess site1 maximum-requests=10000
WSGIProcessGroup site1
WSGIScriptAlias /site1 /var/www/site1/django.wsgi
WSGIDaemonProcess site2 maximum-requests=10000
WSGIProcessGroup site2
WSGIScriptAlias /site2 /var/www/site2/django.wsgi
I was getting errors with that, but with the « process-group » parameter things are running fine. Funny that at http://code.google.com/p/modwsgi/wiki/ConfigurationDirectives the only place where « process-group » is mentioned is in the WSGIImportScript section.
24 août 2010 at 17 h 28 min
Glag I could help
I also find it odd that this parameter isn’t well docuemented, espcially since not using it cause random errors.
14 octobre 2010 at 19 h 15 min
Merci Bien! Thank you! I’ve been tearing my hair out for days over this one, and your fix worked a treat.
7 décembre 2011 at 3 h 10 min
Brilliant. Thanks for this mate.
8 juillet 2012 at 17 h 22 min
J’ai enfin trouvé un article intéréssant sur le thème de can’t adapt type ‘Decimal’ error with Django + Apache + PostgreSQL + Psycopg2 | Le blog d’Étienne Pouliot
9 août 2012 at 9 h 45 min
[...] Sometimes we'd get it once every 10 seconds, sometimes it wouldn't show for days. Finally we found this blog post with a solution, but I wanted to provide my own spin on it. But first (as right now I'm assuming [...]
3 mai 2013 at 5 h 44 min
xcOopd http://www.78NLRvzfIwzacsSvHH4hdZWSkQdHROAk.com